Effacer les filtres
Effacer les filtres

Output of every loop calculation to be used as vector.

1 vue (au cours des 30 derniers jours)
Arif
Arif le 23 Juin 2011
Commenté : Timo Baumann le 14 Fév 2020
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???...

Réponses (1)

Sean de Wolski
Sean de Wolski le 23 Juin 2011
y = zeros(n,1);
for ii = 1:n
y(ii) = some_value_of_x(possibly(ii))
end
  6 commentaires
Stephen23
Stephen23 le 14 Fév 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
Timo Baumann le 14 Fév 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by