Get multiple matrices automatically in workspace
1 回表示 (過去 30 日間)
古いコメントを表示
Dear,
I run an algorithm 50 times using the for loop. I want to save the results after each iteration ie I want to have in the workspace 50 matrices but I always find the last matrix (for i = 50). I apply this loop on all the algorithm. My algorithm contains Randomized values, every execution I have a matrix. I want to have 50 matrix automatically using the For loop but I find the last one in the workspace. Do you have an idea ?
for j=1:50
X = 200 * rand(1,20) - 100;
Y = 200 * rand(1,20) - 100;
for i=1:20
dist = sqrt((X(i)-X(:)).^2+(Y(i)-Y(:)).^2);
distance=[distance dist ];
end
end
Thnaks
2 件のコメント
John D'Errico
2017 年 1 月 2 日
編集済み: John D'Errico
2017 年 1 月 2 日
DON'T make 50 separate matrices.
You need to learn about arrays, and multi-dimensional arrays. Learn to use arrays. That is what makes MATLAB a useful tool.
Stephen23
2017 年 1 月 3 日
"I want to have 50 matrix automatically using the For loop"
Don't do this. Read this to know why:
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!