save result of each iteration in a joint table

4 ビュー (過去 30 日間)
Marko Adamovic
Marko Adamovic 2018 年 6 月 21 日
回答済み: Peter Perkins 2018 年 7 月 3 日
Hi, I am trying to save the results of each iteration as one joint table. However I got only the last one. Any hint? Thanks
for j=1:d %
% some fun to calculate and get results.mat
load results.mat % obsData simData at each loop d
T(:,:)= table(obsData(:),simData(:));
end
  2 件のコメント
KL
KL 2018 年 6 月 21 日
you're doing the exact same thing during every iteration. What are you trying to do here?
Marko Adamovic
Marko Adamovic 2018 年 6 月 21 日
just trying to add every new obs and sim to the Table. Thanks

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

採用された回答

Marko Adamovic
Marko Adamovic 2018 年 6 月 21 日
it works with arrays by simple saving it for obs and sim separately, and then joining them.Thanks

その他の回答 (2 件)

Peter Perkins
Peter Perkins 2018 年 7 月 3 日
You are overwriting all of T every time.
Do one of two things:
1) inside you2 loop, assign to new rows of T:
T(end:end+n,:)= table(obsData(:),simData(:))
or
2) Inside your loop, assign each new table into a cell array, and then vertcat them all.
for i = ...
C{i} = table(obsData(:),simData(:));
end
T = vertcat(C{:});

Sayyed Ahmad
Sayyed Ahmad 2018 年 6 月 21 日
I would use the cell-data format to save every thing.
for i=1:5
x{i}=table('test',i);
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by