フィルターのクリア

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 日間)
Sachin Patil
Sachin Patil 2016 年 8 月 30 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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
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?
Sachin Patil
Sachin Patil 2016 年 8 月 31 日
I want to check for each individual cell. If cell is empty it should be in else condition.

回答 (1 件)

Star Strider
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 件のコメント
Sachin Patil
Sachin Patil 2016 年 8 月 31 日
@Star Strider: Oh I am sorry, actually it is less than 70. done by mistake.
Star Strider
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!

Translated by