Display warning only if the "if "statement is not satisfied

1 回表示 (過去 30 日間)
antonet
antonet 2012 年 7 月 5 日
Hi,
I want to create an if statement that will warn me ONLY if the “if “ is NOT satisfied
I tried initially,
if qs1==q2 | qs1==q3
'OK '
else
'Not ok'
End
But this expression displays also “ok” if the if statement is satisfied. I want to get ONLY the warning “not ok” if the “if” statement is NOT satisfied.
If the if statement is satisfied then I do not want to display “ok”
thanks
  1 件のコメント
TAB
TAB 2012 年 7 月 5 日
if qs1==q2 | qs1==q3
% 'OK ' -- Don't display this
else
'Not ok'
end

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

採用された回答

Luffy
Luffy 2012 年 7 月 5 日
編集済み: Luffy 2012 年 7 月 5 日
if ~(qs1==q2 | qs1==q3)
'Not ok'
end
%If u do not like above 1 do this:
if qs1==q2 | qs1==q3
else
'Not ok'
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by