put each line of matrix in different vector

1 回表示 (過去 30 日間)
sadoune sadoune
sadoune sadoune 2012 年 11 月 24 日
Hi,
I would like to put each line of matrix in vector, The problem is that the number of lines is entered by user (=n).
The name of my matrix is (M)and I want to put each line in different vectors " Seq_i" with i=1:n.
My program :
for i=1:n
strcat('Seq', num2str(i))=M(i,:);
end
with error message
  2 件のコメント
Matt Fig
Matt Fig 2012 年 11 月 24 日
*Don't do it! * See Walter's link, and avoid this bad programming practice.
Jan
Jan 2012 年 11 月 25 日
Follow Matt and Walter!
This question is asked surprisingly often. But hiding an index in the name of a variable is nothing, which would anybody do in the real life. E.g. it would have some advantage to include my weight in my name: it would be trivial to determine my weight without asking or measuring. But the drawbacks are obvious: I have no valid name before I've visited the scale and afterwards I need new accounts in the forum, the office, the driving license and I have to tell the current name to all family members and staff.
Kind regards, Jan71point2

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

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 11 月 24 日

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by