Plotting with nested for loops

7 visualizzazioni (ultimi 30 giorni)
Moslem Uddin
Moslem Uddin il 16 Giu 2020
Commentato: Stephen23 il 16 Giu 2020
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 Commenti
Moslem Uddin
Moslem Uddin il 16 Giu 2020
It gives only only figure. Yes, y is symbolic.
Stephen23
Stephen23 il 16 Giu 2020
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

Accedi per commentare.

Risposta accettata

Moslem Uddin
Moslem Uddin il 16 Giu 2020
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

Più risposte (1)

Rafael Hernandez-Walls
Rafael Hernandez-Walls il 16 Giu 2020
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

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by