how to create different column as a different vector from a matrix
이전 댓글 표시
Hi, I am a new user of matlab. I am having a huge matrix (m,n)and I want to convert n different column vectors. How to do that? for example I am trying to do in following way
a=[1 2 3;4 5 6;7 8 9;10 11 12];
for i = 1 : size(a, 2)
qj = a(:,i)
end
but it is only storing last column . But I want to store like q1= 1 2 3 q2= 4 5 6
and so on please help me this regard. Thanks in advance.
Abhi
채택된 답변
추가 답변 (1개)
Walter Roberson
2011년 9월 13일
0 개 추천
댓글 수: 3
Abhinav
2011년 9월 14일
Jan
2011년 9월 14일
@Abhinav: The FAQ tells, that it is much more efficient to use the columns of a large array, that to split the array into vectors. Using variables called q1, q2, q3, ... will lead to problems and makes the code slow, hard to expand (if you need more vectors, you have to edit all occurences) and much harder to debug. Therefore it is recommended to use q(:,i) directly instead.
Please take into account, that this topic is included in the FAQ, because it leads to problems very frequently.
Abhinav
2011년 9월 15일
카테고리
도움말 센터 및 File Exchange에서 HDF4 Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!