How can i save after each loop the variable in the same vector?
1 回表示 (過去 30 日間)
古いコメントを表示
Hey everybody,
I have a problem. I was writing a for loop. After the loop everytime the solution is printed to a textdocument. After the loop I load the text file again and work with this variables. Is it easier to store the solutions in a vector instead of a textfile. Is there any possibility to change that?
I looking forward to hearing about someones help.
Kind regards Chris
0 件のコメント
採用された回答
Chandrasekhar
2014 年 4 月 8 日
Hi Chris. Its better to maintain a vector of the results instead of writing into a text file and again loading it. If you want to save the data then you can save in the .mat format which you can reuse later.
2 件のコメント
Chandrasekhar
2014 年 4 月 8 日
編集済み: Chandrasekhar
2014 年 4 月 8 日
For eg:
vec = [];
for i = 1:10
vec(i) = i;
end
eval('save vector vec');
vec is vector of 10 values of every loop without overwriting. vector.mat contains the vec variable
その他の回答 (1 件)
Abhishek M
2014 年 4 月 8 日
編集済み: Abhishek M
2014 年 4 月 8 日
Hi Chris,
Try this
A=10;
b=10;
for i=1:b
A(i)=%%logic;
end
for l=1:b
matA{l,:}=A; %%%% responsible for holding old iteration values
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Language Support についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!