How can I make this matrix ?
1 view (last 30 days)
Show older comments
0 Comments
Accepted Answer
Voss
on 13 Dec 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 Comments
Voss
on 14 Dec 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.
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!