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 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
SANJOY MONDAL
am 4 Jun. 2018
Kommentiert: SANJOY MONDAL
am 4 Jun. 2018
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 Kommentare
Akzeptierte Antwort
Stephen23
am 4 Jun. 2018
>> 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numeric Types finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!