# Add 2d plots along a 3d helix

7 views (last 30 days)
Vivi on 13 Feb 2020
Commented: Vivi on 13 Feb 2020
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 on 13 Feb 2020
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); Vivi on 13 Feb 2020
Thank you but i want two plots where the first one is a plot of x against theta and then seconf a plot of y against theta as well.
Subhadeep Koley on 13 Feb 2020
@ Vivi I am not sure but it seems you want something like below
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;
plot3(x, y, z, 'b');
xlabel('x');
ylabel('y');
zlabel('z');
grid on; box on;
hold on;
% Plot x against theta
axis([-101 101 -101 101 -1 36]);
SX = size(x);
Y3 = 101 * ones(SX);
plot3(x, Y3, z, 'r', 'LineWidth', 1.5);
% Plot y against theta
SY = size(y);
X3 = 101 * ones(SY);
plot3(X3, y, z, 'g', 'LineWidth', 1.5);
hold off; Vivi on 13 Feb 2020
That's the one. Thank you!