create a new matrix for every iteration of a loop

2 ビュー (過去 30 日間)
Locks
Locks 2014 年 9 月 15 日
コメント済み: Locks 2014 年 9 月 15 日
Hi,
I have the following problem:
for k=1:10
varOfInt=strcat('mydata',num2str(k))
genvarname(varOfInt)
end
Doing this, I get the following error message: Index exceeds matrix dimensions.
What I am trying to do is the following: I like to create a new matrix with each iteration (3 dim array does not work because the dimensions are not identical) and give those matrices the name mydata1, mydata2, etc. and then save the read in input in those created variables.
Is there anybode who has a solution to this problem?
Regards

採用された回答

Adam
Adam 2014 年 9 月 15 日
Use a cell array. Individually named variables created in a loop are not at all a good idea.
  1 件のコメント
Locks
Locks 2014 年 9 月 15 日
will do so, thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by