Create workspace file automatically.
3 ビュー (過去 30 日間)
古いコメントを表示
Let's say I have:
a = {'one' 'two' 'three'};
b = [1 2 3];
I want each word create a file in workspace automatically and equal to number. Like:
one=1; two=2; three=3;
0 件のコメント
採用された回答
Brett Shoelson
2011 年 2 月 10 日
I think you mean "variable," not "file." Right?
for ii = 1:numel(a)
eval(sprintf('%s = %d',a{ii},b(ii)));
end
Cheers,
Brett
2 件のコメント
その他の回答 (2 件)
Walter Roberson
2011 年 2 月 10 日
This is generally considered poor programming and hard to maintain. Please see the FAQ answer on this topic for alternatives.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT-Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!