MATLAB Answers

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

7 views (last 30 days)
Ana Bianco
Ana Bianco on 17 Sep 2019
Commented: Ana Bianco on 17 Sep 2019
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

  0 Comments

Sign in to comment.

Accepted Answer

per isakson
per isakson on 17 Sep 2019
Edited: per isakson on 17 Sep 2019
"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

More Answers (0)

Sign in to answer this question.