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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops 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