How can I make this matrix ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Akzeptierte Antwort
Voss
am 13 Dez. 2022
% your matrix:
i = 0; m = 1; j = 2; n = 3;
M = repmat([i i i m m j j j n n],4,1)
% delete columns 4-5 and 9-10:
M(:,[4 5 9 10]) = []
4 Kommentare
Voss
am 14 Dez. 2022
Suppose you want to delete columns 4, 9, 14, ... and columns 5, 10, 15, ...
M = reshape(1:100,4,[])
spacing = 5;
N_Cols = size(M,2);
col_to_delete = [4:spacing:N_Cols 5:spacing:N_Cols];
M(:,col_to_delete) = []
No loop necessary.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!