function handles to save data
1 回表示 (過去 30 日間)
古いコメントを表示
I want to save the Output for every round my loop takes. The Problem; I need an handle and my m-file has no Objects. The Question: How do i define a handle which i can use to store my data.
3 件のコメント
採用された回答
Geoff Hayes
2014 年 8 月 19 日
Max - try the following. Suppose the output from one iteration of your loop is a 1x9 vector, and that there are 25 iterations. That means we need a 25x9 matrix:
maxIters = 25;
allData = zeros(maxIters,9);
for k=1:maxIters
% do some work that results in a 1x9 vector
output = ones(1,9);
% save the output to the kth row of the allData matrix
allData(k,:) = output;
end
And that is it. Once outside of the for loop, allData has the output from each iteration.
Try the above and see what happens!
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!