Organize the logic to transform given matrix into required
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Muhammad Taha
am 23 Jan. 2022
Beantwortet: Voss
am 23 Jan. 2022
Given
[1 5 4 5 7
2 5 5 5 8
3 5 6 5 9]
Required
[1 2 3
4 5 6
7 8 9]
0 Kommentare
Akzeptierte Antwort
Voss
am 23 Jan. 2022
A = [1 5 4 5 7; 2 5 5 5 8; 3 5 6 5 9]
B = A.'; % transpose
B = B(1:2:end,:) % take every alternate row, starting with 1st
Or:
B = A(:,1:2:end).' % take every alternate column, then transpose
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays 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!