how to store values from loop in an array?

조회 수: 1 (최근 30일)
kitty varghese
kitty varghese 2017년 8월 8일
편집: kitty varghese 2017년 8월 8일
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