How can I save matrices created in a for loop in the workspace?

1 回表示 (過去 30 日間)
Dario
Dario 2018 年 3 月 10 日
コメント済み: Stephen23 2018 年 3 月 10 日
This is my code at the moment:
for f=1:3
diff_matr=[dist_direct(:,f),diff(:,f)];
diff_matr=sortrows(diff_matr,1); % matrice diff_matr ordinata secondo la distanza in linea d'aria
figure
plot(diff_matr(:,1),diff_matr(:,2), '.')
title('Delay paths distribution over the distance')
end
where:
dist_direct 472615x3
diff 472615x3
And my question is: how I can save in my workspace as variables all the matrices I create inside the for cycle?
  1 件のコメント
Stephen23
Stephen23 2018 年 3 月 10 日
It is simple and efficient to store the matrices during the loop (using indexing) and then save them all at once after the loop. Have you tried doing that?

サインインしてコメントする。

回答 (1 件)

David Fletcher
David Fletcher 2018 年 3 月 10 日
I'm not entirely certain I'm fully getting the gist of your question but,
save(filename)
will save all workspace variables to the specified file. If you just wanted to save specific variables you can use:
save(filename,'varname1','varname2',...)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by