save result of each iteration in a joint table
2 views (last 30 days)
Show older comments
Marko Adamovic
on 21 Jun 2018
Answered: Peter Perkins
on 3 Jul 2018
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
Accepted Answer
More Answers (2)
Peter Perkins
on 3 Jul 2018
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{:});
0 Comments
Sayyed Ahmad
on 21 Jun 2018
I would use the cell-data format to save every thing.
for i=1:5
x{i}=table('test',i);
end
0 Comments
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!