How to form a matrix based on the order of input

1 visualización (últimos 30 días)
ASHA PON
ASHA PON el 2 de Dic. de 2022
Comentada: ASHA PON el 12 de Dic. de 2022
I am having a set of input. Now, I have to form a matrix based on its order whose row indicates ascending order of input and column indicates the actual order of input.
Example:
Input= 110
101
011
111
100
001
010
Expected matrix:
Row Column
1 2 3 4 5 6 7
001 0 0 0 0 0 1 0
010 0 0 0 0 0 0 1
011 0 0 1 0 0 0 0
100 0 0 0 0 1 0 0
101 0 1 0 0 0 0 0
110 1 0 0 0 0 0 0
111 0 0 0 1 0 0 0

Respuesta aceptada

Davide Masiello
Davide Masiello el 2 de Dic. de 2022
Editada: Davide Masiello el 2 de Dic. de 2022
Input= [110 101 011 111 100 001 010];
M = Input == sort(Input)'
M = 7×7 logical array
0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by