Clear Filters
Clear Filters

Save matrix of each iteration

1 view (last 30 days)
I have the following code:
for c=1:10;
D = maximin(n2,n1,'euclidean');
M = min(D,[],2); ;
C=[D M];
[maxValue, rowIdx] = max(C(:,end),[],1); %max value and the row index
n1(end+1,:) = n2(rowIdx,:); %Copy selected row to bottom of n1
n2(rowIdx,:) = []; %Delete the row from n2 that has the maximin
c=c+1;
end
n1 is 50*80 and n2 is 100*80 At the end of first iteration n1=51*80 and n2=49*80 and so on. I need to see save the n1 at the end of each iteration, so that I can use n1(1) ... n1(10) for further calculation. Please help. I treid B = cell(1, c); B(n) = n1(1, c+1); Didn't help. Any help is very much appreciated.
Thanks

Accepted Answer

Walter Roberson
Walter Roberson on 16 Sep 2013
  1 Comment
Sincloe Brans
Sincloe Brans on 16 Sep 2013
Thanks for the answer. It kind of works, the n1...n10 are withing B matrix. In other words, B is 1*10 cell, each cell has each of the n's. Not sure how to split or separate them so that B1, B2... corresponds n1, n2 etc.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements 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!