How to extract a vector from a matrix and save in workspace?

2 ビュー (過去 30 日間)
Ana Bianco
Ana Bianco 2019 年 9 月 17 日
コメント済み: Ana Bianco 2019 年 9 月 17 日
Hi all, so I have a matrix, for example:
M = [2 5 8
3 6 9
4 7 10]
I want to extract each column vector [2; 3; 4] and save them with names like: vector_1, vector_2... and so forth
Is it possible? and if so, can I use them in a loop using their names?
like this (totally wrong)
for i = 1: quantity of vectors
vector_1.....
Is it possible?
Thank you in advance

採用された回答

per isakson
per isakson 2019 年 9 月 17 日
編集済み: per isakson 2019 年 9 月 17 日
"can I use them in a loop using their names" NO
but you can loop over the columns of the matrix
for jj = 1 : size( M, 1 )
M( :, jj )
end
  1 件のコメント
Ana Bianco
Ana Bianco 2019 年 9 月 17 日
Perfect! Sounds good!
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by