how to store values from loop in an array?

v=[1 2 3;4 5 6;7 8 9]
l2=zeros(3,1)
for i=1:3
l2=norm(v((i),:),2)
end
i want to store store l2 values in an array.

1 comentario

kitty varghese
kitty varghese el 8 de Ag. de 2017
Editada: kitty varghese el 8 de Ag. de 2017
here is the code u may try
v=[1 2 3;4 5 6;7 8 9]
l2=zeros(3,1)
for i=1:3 l2(i,:)=norm(v((i),:),2) end

Iniciar sesión para comentar.

 Respuesta aceptada

KSSV
KSSV el 8 de Ag. de 2017
v=[1 2 3;4 5 6;7 8 9] ;
l2=zeros(3,1) ;
for i=1:3
l2(i) = norm(v((i),:),2) ;
end
Read about MATLAB matrix indexing.....

Más respuestas (0)

Categorías

Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 8 de Ag. de 2017

Editada:

el 8 de Ag. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by