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

Hello,
How can we save the output of a loop when it is a series of matrices
Thank you,

 채택된 답변

Stephen23
Stephen23 2015년 4월 25일
편집: Stephen23 2019년 6월 19일

1 개 추천

댓글 수: 2

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 2015년 4월 26일
편집: Stephen23 2015년 6월 3일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

질문:

Sha
2015년 4월 24일

편집:

2019년 6월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by