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

Status
Not open for further replies.

#### davyzhu

##### Advanced Member level 1
Hello all,

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

Davy

#### cedance

##### Advanced Member level 2
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

#### Element_115

##### Advanced Member level 2
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

#### btwang

##### Newbie level 5
it should be "if(x==1&y==0)"in matlab

#### YUV

##### Advanced Member level 4
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.