Plotting with nested for loops

조회 수: 14 (최근 30일)
Moslem Uddin
Moslem Uddin 2020년 6월 16일
댓글: Stephen23 2020년 6월 16일
I have resolved the issue with the following code:
clc, clear all
syms y
t=[0 pi 2*pi];
a=[5 10];
for k=1:length(a)
for j=1:length(t)
f=a(k)*sin(t(j)*y);
fplot(y,f);hold on;
end
end
  댓글 수: 3
Moslem Uddin
Moslem Uddin 2020년 6월 16일
It gives only only figure. Yes, y is symbolic.
Stephen23
Stephen23 2020년 6월 16일
Original question retrieved from Google Cache:
I want to plot multiple figures using nested for loop, but failed to generate plot. I used the following code:
clc, clear all
syms y
t=[0 pi 2*pi];
a=[5 10];
for k=1:length(a)
for j=1:length(t)
f=a(k)*sin(t(j)*y);
fplot(y,f);
end
end

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

채택된 답변

Moslem Uddin
Moslem Uddin 2020년 6월 16일
clc, clear all
syms y
t=[0 pi 2*pi];
a=[5 10];
for k=1:length(a)
for j=1:length(t)
f=a(k)*sin(t(j)*y);
fplot(y,f);hold on;
end
end

추가 답변 (1개)

Rafael Hernandez-Walls
Rafael Hernandez-Walls 2020년 6월 16일
syms y
t=[0 pi 2*pi];
a=[5 10];
for k=1:length(a)
for j=1:length(t)
f=a(k)*sin(t(j)*y);
figure %only with this line
fplot(y,f);
end
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by