"if (x==1 && y==0)" in Matlab

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
Hello all,

How to do "if (x==1 && y==0)" in Matlab, the "if (x==1 && y==0)" is in C. Thanks!

Davy
 

hi,

see the matlab documentation..

u could see the matlab help for these sort of things.. or type "help if" in the command window and u would get it known from there...

nyways, the command is,
if ( a ==b & c ==d )
command........
end

also see here:
/http://www-ccs.ucsd.edu/matlab/techdoc/ref/if.html

/cedance
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
In Matlab always use the help command it's a good tool to have!
help if
help &

This should help you in the future! As for you question.

if (x==1 & y==0);

That works

Peace
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
it should be "if(x==1&y==0)"in matlab
 

davyzhu said:
Hello all,
How to do "if (x==1 && y==0)" in Matlab, the "if (x==1 && y==0)" is in C. Thanks!
Davy
If I were you, I would add extra round brackets
if ((x==1) & (y==0))
to be sure in order of operations. Also, it's much better readable.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…