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 commentaires

Geoff Hayes
Geoff Hayes le 16 Juin 2020
Moslem - please clarify what you mean by failed to generate plot. Were any plots generated or none? Or just one? Or do you see an error?
I also wonder if you mean for y to be a "sym".
Moslem Uddin
Moslem Uddin le 16 Juin 2020
It gives only only figure. Yes, y is symbolic.
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

Connectez-vous pour commenter.

 Réponse acceptée

Moslem Uddin
Moslem Uddin le 16 Juin 2020

0 votes

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

Plus de réponses (1)

Rafael Hernandez-Walls
Rafael Hernandez-Walls le 16 Juin 2020

0 votes

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

Catégories

En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange

Produits

Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by