【发布时间】:2013-09-16 16:03:13
【问题描述】:
我有以下代码:
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 为 50*80,n2 为 100*80 在第一次迭代结束时,n1=51*80 和 n2=49*80 以此类推。我需要在每次迭代结束时保存 n1,以便我可以使用 n1(1) ... n1(10) 进行进一步计算。请帮忙。我尝试了以下
B = cell(1, c); B(n) = n1(1, c+1); and
B{n} = n1;
没有帮助。非常感谢任何帮助。
谢谢
【问题讨论】:
-
您收到了什么错误信息?您将第二段代码放在循环中的哪个位置?
-
我把它放在“c=c+1”语句的正上方。使用 B{n}. 时我没有收到错误,而是得到一个 1* 10 矩阵,其中每个单元格由 n 个(n1..n10 在 10 个单元格中)组成。它就像整个 n1 矩阵在 B{n} 的一个单元格中