i have a matrix like [1 0 0 1 0 1 0 ; 0 1 0 1 0 0 ; 1 0 0 1 1 1]. there are 3 rows and 7 column i wanna to see in the format like
조회 수: 1 (최근 30일)
이전 댓글 표시
i have a matrix like [1 0 0 1 0 1 0 ; 0 1 0 1 0 0 ; 1 0 0 1 1 1]. there are 3 rows and 7 column i wanna to see in the format like [ 1 1 1; 1 2 0; 1 3 0; 1 4 1; 1 5 0 ; 1 6 1; 1 7 0; 2 1 ; 2 2...;]
댓글 수: 0
채택된 답변
Stephen23
2018년 6월 4일
>> M = [1 0 0 1 0 1 ; 0 1 0 1 0 0 ; 1 0 0 1 1 1]
M =
1 0 0 1 0 1
0 1 0 1 0 0
1 0 0 1 1 1
>> S = size(M);
>> [R,C] = ndgrid(1:S(1),1:S(2));
>> sortrows([R(:),C(:),M(:)])
ans =
1 1 1
1 2 0
1 3 0
1 4 1
1 5 0
1 6 1
2 1 0
2 2 1
2 3 0
2 4 1
2 5 0
2 6 0
3 1 1
3 2 0
3 3 0
3 4 1
3 5 1
3 6 1
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numeric Types에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!