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 件のコメント

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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2017 年 8 月 8 日

編集済み:

2017 年 8 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by