MATLAB: How to make 3D-line plots (Sine Wave)

3d plotsmatrixplot

Hi everybody, I am new to MATLAB and I need a help with this problem.
Plot a series of sine functions which are phase shifted by pi/10 and whose amplitudes are increased by 0.2. Final result is going to be like this. I tried bunch of methods but I couldn't get it. Thanks in advance.
sinewaves.png

Best Answer

With three small changes to your code, it works:
t = 0:0.01:5*pi;
z = 0:pi/12:2*pi;
phase = 0; % Initiliise Outside The Loop
a = 1:0.2:4; % Assign Outside The Loop
for k = 1:numel(a)
y(k,:) = a(k)*sin(t + phase);
phase = phase + pi/10;
% disp(y)
end
axes()
hold on
for i = 1:numel(z)
plot3(t,z(i)*ones(size(t)),y);
end
The changes are with respect to ‘phi’ and ‘phase’, and adding the ‘k’ loop counter and subscript.
My solution:
t = linspace(0, 4*pi);
a = (1:25);
sinmtx = 0.2*a(:).*sin(t + a(:)*pi/10);
figure
plot3(t, a(:)*ones(size(t)), sinmtx)
grid on
view(35,45)