How can I make this matrix ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1229847/image.png)
0 commentaires
Réponse acceptée
Voss
le 13 Déc 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 commentaires
Voss
le 14 Déc 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!