Borrar filtros
Borrar filtros

How to restore output of for loop in matrix

1 visualización (últimos 30 días)
muhammad ismat
muhammad ismat el 29 de Sept. de 2018
Respondida: muhammad ismat el 29 de Sept. de 2018
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

Respuesta aceptada

Stephen23
Stephen23 el 29 de Sept. de 2018
Editada: Stephen23 el 29 de Sept. de 2018
mat = zeros(10,2);
for ii = 1:10
for jj = 1:2
mat(ii,jj) = sum((sam(ii,:)-cen(jj,:)).^2);
end
end

Más respuestas (1)

muhammad ismat
muhammad ismat el 29 de Sept. de 2018
Thank you very much

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by