How to restore output of for loop in matrix

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

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

Più risposte (1)

muhammad ismat
muhammad ismat il 29 Set 2018
Thank you very much

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by