Azzera filtri
Azzera filtri

Plotting curve for the values of for loop

1 visualizzazione (ultimi 30 giorni)
Chinmayraj Doddarajappa
Chinmayraj Doddarajappa il 15 Ago 2022
Risposto: Walter Roberson il 15 Ago 2022
I've written a script that uses a for loop to calculate a specific value. After each loop iteration, the value of the variable is updated. How can I save the variable's value in an array so that I can use it to plot a curve later?
Thanks in advance.
For example, 
N = 1:1:5
for i=1:length(N)
Performs calculation
S = output
end
I need to plot (N,S)
Sample test code is attached.

Risposte (1)

Walter Roberson
Walter Roberson il 15 Ago 2022
N = 1:1:5
for i=1:length(N)
Performs calculation
S(:,i) = output(:);
end
This will create one column for each entry in N.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by