Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

Asked by antonet on 5 Jul 2012

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 Comment

TAB on 5 Jul 2012
if qs1==q2 | qs1==q3
% 'OK ' -- Don't display this
else
 'Not ok'
end
antonet

Products

No products are associated with this question.

1 Answer

Answer by Luffy on 5 Jul 2012
Edited by Luffy on 5 Jul 2012
Accepted answer
 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

1 Comment

antonet on 5 Jul 2012

thanks luffy

Luffy

Contact us