create matrix from string name
1 回表示 (過去 30 日間)
古いコメントを表示
I want to create multiple matrices but i do not want to name each one but instead make matlab initialise one with every loop iteration.
I created var = "a",i = i+1,and then var = "a" + i, which would give me "a1", and then "a2", and so on. i want to make n x n matrices called a1, and another called a2, and so on.Each matrix is a (2:end,2:end) version of the previous one.
1 件のコメント
KSSV
2019 年 4 月 15 日
YOu need not name each matrix........read about 3D matrices.
a = rand(2,2,2) ;
a(:,:,1) % a1
a(:,:,2) % a2
回答 (1 件)
madhan ravi
2019 年 4 月 15 日
https://in.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval - use cell or a ND array. For example:
a=cell(4,1);
for k=1:4
a{k} = rand(2);
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!