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

 Akzeptierte Antwort

Stephen23
Stephen23 am 25 Apr. 2015
Bearbeitet: Stephen23 am 19 Jun. 2019

1 Stimme

2 Kommentare

Sha
Sha am 26 Apr. 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 am 26 Apr. 2015
Bearbeitet: Stephen23 am 3 Jun. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

Sha
am 24 Apr. 2015

Bearbeitet:

am 19 Jun. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by