Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: How to use the relational operators with IF stetment ?
Replies: 1   Last Post: Mar 24, 2013 12:09 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
sam

Posts: 27
Registered: 8/19/12
How to use the relational operators with IF stetment ?
Posted: Mar 24, 2013 11:56 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello, I have problem when used the relational operators such as (== , ~= , >=) with the IF statement.

Below the code that explain the problem:

clc;
RA=[0 1 1 1 ; 1 1 1 0];
E0=[0 0 0 0];
e=0;
RB=0;

if (all(RA(1,:)== E0) && all(RA(2,:) == E0))
e=e+2;
elseif ( all(RA(1,:)== E0) && all(RA(2,:) ~= E0))
PP3=RA(2,:)
e=e+1;
elseif ( all(RA(1,:)~= E0) && all(RA(2,:) == E0))
PP1=RE(1,:)
e=e+1;
elseif ( all(RA(1,:)~= E0) && all(RA(2,:) ~= E0))
e=e+0;
RB=RA
end
--------------

After RUN the results

RB= 0



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.