MATLAB Answers


Finding remaining numbers in logical indexing?

Holly Robinson さんによって質問されました 2019 年 5 月 14 日
最新アクティビティ Holly Robinson さんによって コメントされました 2019 年 5 月 14 日
How would you find how many numbers in an array do not meet any of the previous conditions without using else if statements?
I want to return all the numbers that do not meet the previous conditions listed, but I can't figure out how to do that without using if else statements.
sum(find(:) == 1)
find=(length < 3) & (max_width_head > mean_width_neck*2);
sum(find(:) == 1)
disp('long thin')
sum(find(:) == 1)

  2 件のコメント

James Tursa
2019 年 5 月 14 日
You are really going to confuse your readers by using the names "find" and "length" as variable names ... they shadow important MATLAB functions. I would advise using different names.
madhan ravi
2019 年 5 月 14 日
First and foremost your variable naming is totally a bad idea and second of all what is the input and what output are you expecting?

サインイン to comment.

1 件の回答

James Tursa
回答者: James Tursa
2019 年 5 月 14 日

find1 = length<1;
find2 = (length < 3) & (max_width_head > mean_width_neck*2);
find3 = max_width_head>=mean_width_neck;
sum(~(find1 | find2 | find3)) % the number that don't match any of the previous conditions

  1 件のコメント

Holly Robinson 2019 年 5 月 14 日
That worked perfectly thank you so much!!

サインイン to comment.

Translated by