Splitting a row matrix to different rows
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a Matrix as:
A = [1 3 2 4; 3 1 5 0 ];
and I would like to convert it to a matrix like this:
B=[ 1 3; 1 2; 1 4; 3 1; 3 5; 3 0]
I would appreciate any help.
댓글 수: 2
Jan
2021년 10월 7일
You forgot to mention the method. There is an infinite number of algorithms to construct a matrix based on another matrix. In your case the number of elements grws from 8 to 12. The chance to guess correctly, what you are looking for, is very small.
채택된 답변
Voss
2021년 10월 7일
Here's one way, if I am interpreting your method correctly:
B = [repelem(A(:,1),size(A,2)-1) reshape(A(:,2:end).',[],1)];
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!