Saving the output of a loop into a matrix or a vector

1 vue (au cours des 30 derniers jours)
Sha
Sha le 24 Avr 2015
Modifié(e) : Stephen23 le 19 Juin 2019
Hello,
How can we save the output of a loop when it is a series of matrices
Thank you,

Réponse acceptée

Stephen23
Stephen23 le 25 Avr 2015
Modifié(e) : Stephen23 le 19 Juin 2019
  2 commentaires
Sha
Sha le 26 Avr 2015
Thank you very much for your detailed reply. I am trying to go through the links to get a better understanding of the problem.
"if you continue to include data in the variable names then you will find yourself fighting many more of these battles against MATLAB"
For example I can start using " X = sym('X',[3 8])" which gives me my 24 variables in a matrix, but then what I would like to do is make "column" 1 or index "1" correspond to state "HHH" then column 2 "LHH" (I permute the 2 letters in sequences of "3" so I get 8 possibilities). Is there an easy way to do that ?
Thank you very much
Stephen23
Stephen23 le 26 Avr 2015
Modifié(e) : Stephen23 le 3 Juin 2015
Sorry, I do not use sym, so I have no advice on that. Mixing data (your "states") and the variables' names is what is not recommended, as should be clear from those links.
  • You could create a separate (cell?) array to store those states and whose columns correspond to the columns of the data matrix. This would be a typical and easy MATLAB solution.
  • You might find that using a table suits your needs better than a simple matrix.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by