Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

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: Re: 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: Re: 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

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics