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 visualización (últimos 30 días)
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...;]

Respuesta aceptada

Stephen23
Stephen23 el 4 de Jun. de 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

Más respuestas (0)

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by