How to restore output of for loop in matrix

1 次查看(过去 30 天)
If i have the code
For i=1:10
tmp1=zeros(i,k);
for k=1:2
tmp1(k)=sum((sam(i,:)-cen(k,:)).^2);
end
tmp1
end
i want to store the variable tmp1 in matrix 10× 2

采纳的回答

Stephen23
Stephen23 2018-9-29
编辑:Stephen23 2018-9-29
mat = zeros(10,2);
for ii = 1:10
for jj = 1:2
mat(ii,jj) = sum((sam(ii,:)-cen(jj,:)).^2);
end
end

更多回答(1 个)

muhammad ismat
muhammad ismat 2018-9-29
Thank you very much

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by