for文で連続する数字から変数を定義したい
27 ビュー (過去 30 日間)
表示 古いコメント
採用された回答
Keita Abe
2022 年 10 月 20 日
配列でname(i)を定義するのではなく変数名自体に連番を振るにはevalを使えばできるみたいです。(推奨されないそうですが)
https://jp.mathworks.com/matlabcentral/answers/1729850-for?s_tid=answers_rc1-3_p3_MLT
for i = 1:10
kazu = i;
eval(sprintf('name%d=kazu;',i));
end
whos
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!