Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 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

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

Date Subject Author
3/24/13 sam
3/24/13 James Tursa