Add 2d plots along a 3d helix

조회 수: 4 (최근 30일)
Vivi
Vivi 2020년 2월 13일
댓글: Subhadeep Koley 2020년 9월 14일
Hello.
I have a simple helix that I've plotted by using the following code:
r=93.36;
theta=0:pi/50:10*pi;
%Trajectory in x-direction
x=-r.*cos(theta);
%Trajectory in y-direction
y=r.*sin(theta);
%Trajectory in z-direction
z=theta;
figure(1);
plot3(x,y,z);
xlabel('x');
ylabel('y');
zlabel('z');
grid on
My goal now is to also plot on the same graph the x and y components of the helix given from the equations above.
Thank you.

채택된 답변

Subhadeep Koley
Subhadeep Koley 2020년 2월 13일
Use this
close all; clc;
r=93.36;
theta=0:pi/50:10*pi;
%Trajectory in x-direction
x=-r.*cos(theta);
%Trajectory in y-direction
y=r.*sin(theta);
%Trajectory in z-direction
z=theta;
figure(1);
plot3(x,y,z);
xlabel('x');
ylabel('y');
zlabel('z');
grid on
hold on;
plot(x, y, 'r', 'LineWidth', 3);
  댓글 수: 5
connor brisebois
connor brisebois 2020년 9월 14일
could you explain te use of colon operators in the definition of theta?
Subhadeep Koley
Subhadeep Koley 2020년 9월 14일
Refer to the below link for a detailed explanation.
https://www.mathworks.com/help/matlab/ref/colon.html#bvhfyce

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by