how to store values from loop in an array?

1 次查看(过去 30 天)
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 个评论
kitty varghese
kitty varghese 2017-8-8
编辑:kitty varghese 2017-8-8
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

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2017-8-8
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.....

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by