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:
second digit

Subject: second digit

From: Jessica

Date: 13 May, 2008 15:22:03

Message: 1 of 3

If I have

A = 23

Is there a way to specify the second digit so that

B=3?

Thanks!

Subject: second digit

From: Dave Robinson

Date: 13 May, 2008 15:30:29

Message: 2 of 3

"Jessica " <jyorzinski@ucdavis.edu> wrote in message
<g0cbmr$960$1@fred.mathworks.com>...
> If I have
>
> A = 23
>
> Is there a way to specify the second digit so that
>
> B=3?
>
> Thanks!

B = mod(A,10);

maybe?

Regards

Dave Robinson

Subject: second digit

From: John D'Errico

Date: 13 May, 2008 15:43:48

Message: 3 of 3

In article <g0cbmr$960$1@fred.mathworks.com>, "Jessica " <jyorzinski@ucdavis.edu> wrote:

> If I have
>
> A = 23
>
> Is there a way to specify the second digit so that
>
> B=3?

Many ways, but you need to be more specific.

Do you mean just the units digit? OR do you
want the second most significant digit? Will
A always be a positive integer?

B = floor(A) - 10*floor(A/10)

If A can be negative, we might use this:

B = abs(fix(A) - 10*fix(A/10))

John


--
The best material model of a cat is another, or preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945

Those who can't laugh at themselves leave the job to others.
Anonymous

Tags for this Thread

No tags are associated with 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