replace the rows of a matrix with binary digit values
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
pavlos
am 15 Feb. 2014
Beantwortet: Azzi Abdelmalek
am 15 Feb. 2014
Hello,
Consider the following matrix:
A=[ 1 1 1 1;2 2 2 2;3 3 3 3...]
The row sequence of 1 1 1 1, 2 2 2 2, 3 3 3 3 is repeating.
How can we change all the rows of
1 1 1 1 with 1 0 0 0
2 2 2 2 with 0 1 0 0
3 3 3 3 with 0 0 1 0
Thank you very much.
Best,
Pavlos
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 15 Feb. 2014
A=[ 1 1 1 1;2 2 2 2;3 3 3 3;2 2 2 2;3 3 3 3]
s=[1 0 0 0;0 1 0 0;0 0 1 0];
out=s(A(:,1),:)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!