How to make 3D-line plots (Sine Wave)?
18 ビュー (過去 30 日間)
古いコメントを表示
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.

9 件のコメント
Adam Danz
2019 年 11 月 21 日
Glad I could help - I think you would have gotten there on your own which is a great learning process. Take time to understand each line of the answer that Star Strider gave to you so you can own the assignment and understand why it works.
採用された回答
Star Strider
2019 年 11 月 21 日
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)
0 件のコメント
その他の回答 (1 件)
Adam Danz
2019 年 11 月 21 日
編集済み: Adam Danz
2019 年 11 月 21 日
Since this seems like homework, my solution below shows how to produce the figure but you'll need to adapt it to comply with the requirements of the assignment.
t = 0:0.01:5*pi;
y = sin(t);
z = 0:pi/12:2*pi;
clf()
axes()
hold on
for i = 1:numel(z)
plot3(t,z(i)*ones(size(t)),y);
end
grid on
xlabel('t')
ylabel('o.5 pi') % Replace with ylabel(['0.5',char(960)]) for pi symbol
zlabel('sin(t)')
view(12.6, 27.6)

0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
