remove cell array content matrix with condition: length of element in cell smaller than specific value

1 visualizzazione (ultimi 30 giorni)
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]}

Risposta accettata

Alex Mcaulley
Alex Mcaulley il 21 Mag 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) = [];

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by