Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
I have data as shown, and I am using if statement but it is giving error as, Undefined function 'lt' for input arguments of type 'cell', please help?
조회 수: 1 (최근 30일)
이전 댓글 표시
ca =
[ 1.3589]
[ 7.9773]
[28.2728]
[28.2728]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0.8705]
[ 7.4681]
[28.2728]
[37.0303]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
if (0<ca)&&(ca>70)
do this
else
do this
end
댓글 수: 2
Thorsten
2016년 8월 30일
Do you want to do "this" it the condition is true for all elements, or do you want to check each individual cell? And what should happen if the cell is empty?
답변 (1개)
Star Strider
2016년 8월 30일
편집: Star Strider
2016년 8월 30일
You can do the comparison with cellfun. I am not certain what your code is doing, so this function can do element-by-element comparisons in a loop, or you can create a logical vector from the entire ‘ca’ cell array:
LF = @(x) cellfun(@(x) ((0<x) & (x>70)) & ~isempty(x), x, 'Uni',0); % Element-By-Element Comparison Function
Lv = LF(ca); % Entire Vector Comparison
Note that none of the elements in ‘ca’ will test true for your conditions.
댓글 수: 4
Star Strider
2016년 8월 31일
Then my function becomes:
LF = @(x) cellfun(@(x) ((0<x) & (x<70)) & ~isempty(x), x, 'Uni',0); % Element-By-Element Comparison Function
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!