reference elements in a matrix based on values in a vector
조회 수: 1 (최근 30일)
이전 댓글 표시
I have the 1x9 vector [5 3 2 6 7 26 4 33 3]
I want to obtain the matrix [5 3 2; 6 7 26; 4 33 3] using completely vectorized code. How can this be done?
As a start, I have vectorized code to build the 3x3 matrix [ 1 2 3; 4 5 6; 7 8 9], so that the values are the vector columns, but I don't know how to do the vectorized referencing.
Thanks
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2014년 2월 23일
편집: Azzi Abdelmalek
2014년 2월 23일
A= [5 3 2 6 7 26 4 33 3]
out= reshape(A,3,[])'
댓글 수: 4
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!