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

Thread Subject:
Even & odd numbers

Subject: Even & odd numbers

From: Hariton Ul'ianov

Date: 11 Aug, 2009 18:21:03

Message: 1 of 6

Hi!
I need to make decision in my program by determining is a variable A odd number or even number:

...
if A=="odd number"
...
end
...

Which function in Matlab 7 can help me to make this???
Thank you very much.

Subject: Even & odd numbers

From: dpb

Date: 11 Aug, 2009 18:25:05

Message: 2 of 6

Hariton Ul'ianov wrote:
> Hi! I need to make decision in my program by determining is a
> variable A odd number or even number:
>
> ... if A=="odd number" ... end ...
>
> Which function in Matlab 7 can help me to make this??? Thank you very
> much.

lookfor modulus

--

Subject: Even & odd numbers

From: Andy

Date: 11 Aug, 2009 18:31:19

Message: 3 of 6

"Hariton Ul'ianov" <tulup@mail.ru> wrote in message <h5scqf$a10$1@fred.mathworks.com>...
> Hi!
> I need to make decision in my program by determining is a variable A odd number or even number:
>
> ...
> if A=="odd number"
> ...
> end
> ...
>
> Which function in Matlab 7 can help me to make this???
> Thank you very much.

if mod(A,2) % if A mod 2 is nonzero, i.e. A is odd
...
end

Subject: Even & odd numbers

From: Klemens Schatka

Date: 11 Aug, 2009 18:35:49

Message: 4 of 6

maybe

if mod(A,2)==1

Klemens

Subject: Even & odd numbers

From: Hariton Ul'ianov

Date: 11 Aug, 2009 18:59:17

Message: 5 of 6

Thahk you very much.
It's working :)

Subject: Even & odd numbers

From: us

Date: 11 Aug, 2009 20:49:18

Message: 6 of 6

"Hariton Ul'ianov" <tulup@mail.ru> wrote in message <h5scqf$a10$1@fred.mathworks.com>...
> Hi!
> I need to make decision in my program by determining is a variable A odd number or even number:
> Which function in Matlab 7 can help me to make this???
> Thank you very much.

a hint:

http://www.mathworks.com/matlabcentral/fileexchange/24278

us

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us