필터 지우기
필터 지우기

delete some matrix in cell with condition

조회 수: 2 (최근 30일)
ha ha
ha ha 2019년 6월 5일
답변: Walter Roberson 2019년 6월 5일
Let's say I have 2 cells, & these 2 cells have relationship(cell_A and cell_B always have same dimension; mean: they have same number of matrix):
cell_A : 1x2 cell class
cell_A={[matrix_A1] [matrix_A2]};%contain 2 matrices
cell_A={[5x3 double] [2x3 double] }={[1 1 1;2 2 2;3 3 3;4 4 4;5 5 5] [11 11 11;0 0 0]};
cell_B : 1x2 cell class
cell_B={[matrix_B1] [matrix_B2]};%contain 2 matrices
cell_B={[4x1 double] [3x1 double] }={[100;6;22;33] [1;5;9]};
Now, i want to use the value in each matrices of cell_B to check corresponding matrix in cell_A.
If any value(vector) in matrix of cell_B is larger than predefined value(10). So, corresponding matrix in cell_A will be maintained.
Example: matrix_B1 have four value: 100;6;22;33. There are exist at least one value larger than 10. So, matrix_A1 will be maintained
matrix_B1 have three value: 1;5;9. There are exist NO value larger than 10. So, matrix_A2 will be deleted
result_cell={[5x3 double]}={[1 1 1;2 2 2;3 3 3;4 4 4;5 5 5]};%after delete some matrix in cell_A

채택된 답변

Walter Roberson
Walter Roberson 2019년 6월 5일
result_cell = A(cellfun(@(Bent) any(Bent(:)>Threshold), B));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by