How to 3D plot a circle with radius of 1 in x y and sine wave in z?

10 ビュー (過去 30 日間)
Hwajin Choi
Hwajin Choi 2021 年 4 月 6 日
コメント済み: Hwajin Choi 2021 年 4 月 6 日
Hello,
I want to 3D plot a circle looks like the image below. (Sorry for the poor drawing) The figure is a circle of radius 1 in xy surface and the circle should have a sine wave in z-direction. It's exactly same shape with pringles chip.

採用された回答

Michael
Michael 2021 年 4 月 6 日
Try this:
%Position of center of chip in 3D space
x0 = 1;
y0 = 1;
z0 = 1;
r = 1;%Radius of chip
d_theta = 2*pi/60; %Differential Angle
th = 0:d_theta:2*pi; %Angle Vector
height = 0.5; %Height of wave in the chip
% Create the x, y, and z positions
x = x0+r*cos(th);
y = y0+r*sin(th);
z = z0+height*sin(2*th);
plot3(x,y,z)
grid on
axis equal
  1 件のコメント
Hwajin Choi
Hwajin Choi 2021 年 4 月 6 日
Exactly what I wanted. Thank you. I appreciate the all commented codes.

サインインしてコメントする。

その他の回答 (1 件)

William
William 2021 年 4 月 6 日
How about this:
theta = linspace(0,2*pi,100);
x = sin(theta);
y = cos(theta);
z = sin(2*theta);
figure();
plot3(x,y,z);
  1 件のコメント
Hwajin Choi
Hwajin Choi 2021 年 4 月 6 日
Thank you for your help, William. It's nice simple and neat code. Although I cannot accept your answer because I already accepted another one, I would like to vote yours. Thank you!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by