Change variable name on each iteration in for loop MATLAB
4 ビュー (過去 30 日間)
古いコメントを表示
I have large array P which is changing size and values in each iteration. I need to be able to change the title of my output array to match the given iteration, i.e. for bin 1.4 I would like output to be p1.4 or p14.
Can anyone help?
for bin = 1:0.1:2;
rows = find(DAT(:,27) > bin);
p{bin} = DAT(rows,:);
end
0 件のコメント
採用された回答
Shaun VanWeelden
2013 年 3 月 14 日
If you changed the name, you would be making a new variable every time and I am not sure it is even possible to do this like you say, instead, here are two solutions:
N = the number of large arrays you have
Make a N x 2 cell array, collectionArray, put the large array in collectionArray{i,1} and the name in collectionArray{i,2} that way the name is easy to retrieve with the information.
Or Make a collectionStruct, and have a field for each array (named p14, etc.) and have your array be the value in that field, so to retrieve the data, you could just say collectionStruct.p14
Hope it helps!
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!