Output of every loop calculation to be used as vector.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Dear Friends,
I want an output element of every loop calculation, which can be used as a separate vector. Following is an example:
Suppose, after very loop(if-else or for) calculation, gives the value of some variable, say x. After coming out of loop, I want to use all the calculated values of x, as a separate vector, say y, so that the vector y will be
y=[1st value of x in 1st loop 2nd value of x in 2nd loop & so on...];
Can any of you please help me to get such output???...
0 Commenti
Risposte (1)
Sean de Wolski
il 23 Giu 2011
y = zeros(n,1);
for ii = 1:n
y(ii) = some_value_of_x(possibly(ii))
end
6 Commenti
Stephen23
il 14 Feb 2020
"Could you please help me with that?"
LIke the examples on this page show, you should loop over indices, not data values.
"I'd like to store the vectors of cs, wsmax, thetas and Wnutz in seperate vectors"
You could use a cell array for that, although I strongly recommend putting indentically-sized numeric data into one numeric array rather than storing it as separate vectors.
Timo Baumann
il 14 Feb 2020
Ok thanks :)
The reason I'd like to store everything in seperate vectors is that I'd like to display every variable depending of another one as I want in order to see the influence of each variable individually.
Thanks again for your help.
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!