Conditional logic if possible empty result query

m1= find((d1 <= r & x(source) < x & x<= x(destination) | ...
d1 <= r & y(source) & y(destination)
This code is not responsible to what I need I need if the first condition give me an empty vector choose the second condition to provide the value for m1

 採用された回答

dpb
dpb 2015 年 1 月 7 日

1 投票

Then separate the two and add the conditional..
condition1 = d1<=r & x(source)<x & x<=x(destination); % first condition logical array
if isempty(condition1)
m1=find(d1<=r & y(source) & y(destination));
else
m1=find(condition1);
end

4 件のコメント

maha ismail
maha ismail 2015 年 1 月 7 日
Thanks dear
maha ismail
maha ismail 2015 年 1 月 7 日
Please check my program because also it doesn't work this is my program and the required function
maha ismail
maha ismail 2015 年 1 月 7 日
I don't know why it doesn't work correctly
dpb
dpb 2015 年 1 月 7 日
What does "doesn't work" mean, specifically? And, the above function contains the original code, not the suggested revision, anyway.
If it's a logic error that the result isn't what you expect, use the debugger and step through to see what/why isn't what you think you're coding. If it's a syntax error, post the complete text and context.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2015 年 1 月 7 日

コメント済み:

dpb
2015 年 1 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by