remove cell array content matrix with condition: length of element in cell smaller than specific value
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Let's say:
cell_A : 1x3 cell class
cell_A={matrix_1 matrix_2 matrix_3 }
cell_A={[5x3 double] [1x3 double] [6x3 double]}={[1 1 1;2 2 2;3 3 3;4 4 4;5 5 5] [11 11 11] [0 0 0;1 1 1;2 2 2;3 3 3;4 4 4;5 5 5]}
matrix_1 [1 1 1;2 2 2;3 3 3;4 4 4;5 5 5] %5-by-3 matrix
matrix_2 [11 11 11] %1-by-3 matrix
matrix_3 [0 0 0;1 1 1;2 2 2;3 3 3;4 4 4;5 5 5] %6-by-3 matrix
If I wanna count how many row of each matrix in cell A, the result is:
ans=[ 5; 1 ;6];
Now, I wanna delete matrix of cell A, If the number row in matrix <2. How can I do that? The result is:
result : 1x2 cell class
result={matrix_1 ; matrix_3 }
result={[5x3 double] [6x3 double]}={[1 1 1;2 2 2;3 3 3;4 4 4;5 5 5] [0 0 0;1 1 1;2 2 2;3 3 3;4 4 4;5 5 5]}
0 commentaires
Réponse acceptée
Alex Mcaulley
le 21 Mai 2019
cell_A = {[1 1 1;2 2 2;3 3 3;4 4 4;5 5 5];[11 11 11];[0 0 0;1 1 1;2 2 2;3 3 3;4 4 4;5 5 5]};
cell_A(cellfun(@size,cell_A,repmat({1},size(cell_A))) < 2) = [];
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and 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!