transform column and row data of logical matrix to vector(N X 2)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
sunghyun chung
am 19 Nov. 2019
Kommentiert: Ridwan Alam
am 19 Nov. 2019
Hello
I would like to transfrom column and row data of logical matrix
to
vector matrix (N X 2)
eg.
** logical matrix
0 0 0 0
0 1 0 0
0 0 0 0
0 0 1 0
0 1 0 1
**to vector matrix (N X 2)
2 2
3 3
5 2
5 4
is there function to perform upper task?
thank you
0 Kommentare
Akzeptierte Antwort
Ridwan Alam
am 19 Nov. 2019
Bearbeitet: Ridwan Alam
am 19 Nov. 2019
logical_matrix = [0 0 0 0; 0 1 0 0; 0 0 0 0; 0 0 1 0; 0 1 0 1];
[i,j] = find(logical_matrix);
vector_matrix = [i,j]
% vector_matrix =
%
% 2 2
% 5 2
% 4 3
% 5 4
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!