How to select data from a cell array based on some condition
이전 댓글 표시
Hi, I am facing a problem with cell array, I have a data, for example, A as below
A = {[0, 5], [-2, 3]; [0,0], [12,-21]};
And I want the output as a cell/array of values greater than 2, like this-
B = {[5], [3]; [0], [12]}
I tried this way but its not working
K = @(data, fn) cellfun(@(x) x(data{:}), fn,'UniformOutput',0);
B = K(A, {@(x) x > 2})
I would appreciate if anybody help me with this
채택된 답변
추가 답변 (1개)
Walter Roberson
2019년 8월 31일
B = cellfun(@(data) max(data), A, 'uniform', 0);
C = cellfun(@(data) min(data), A, 'uniform', 0);
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!