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:
Converting irrational numbers to rational

Subject: Converting irrational numbers to rational

From: William

Date: 31 Jul, 2010 09:58:05

Message: 1 of 3

Sorry, I am very new to matlab. I would like to display my answers in rational numbers instead of scientific notation which I am getting now. Anything helps, really just looking for the help doc that has info on this subject.

Subject: Converting irrational numbers to rational

From: us

Date: 31 Jul, 2010 10:07:23

Message: 2 of 3

"William " <william.baxter@oit.edu> wrote in message <i30s3d$ptm$1@fred.mathworks.com>...
> Sorry, I am very new to matlab. I would like to display my answers in rational numbers instead of scientific notation which I am getting now. Anything helps, really just looking for the help doc that has info on this subject.

a hint:

     help format;

us

Subject: Converting irrational numbers to rational

From: Roger Stafford

Date: 31 Jul, 2010 20:07:05

Message: 3 of 3

"William " <william.baxter@oit.edu> wrote in message <i30s3d$ptm$1@fred.mathworks.com>...
> Sorry, I am very new to matlab. I would like to display my answers in rational numbers instead of scientific notation which I am getting now. Anything helps, really just looking for the help doc that has info on this subject.
- - - - - - - - - -
  Also check out the 'rat' and 'rats' (no relationship with the rodent) matlab functions.

  For some theoretical background read the Wikipedia article at:

 http://en.wikipedia.org/wiki/Continued_fraction

In particular read the section "Best rational approximations".

  Additional note: You mentioned "irrational" numbers in your subject title, but bear in mind that all of matlab's floating points numbers are of necessity rational - in fact they are all integers divided by various powers of two - the smallest positive double precision floating point number is 1/2^1074 and all its other numbers are integer multiples of this.

Roger Stafford

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