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:
show the whole numbers...how

Subject: show the whole numbers...how

From: alfann

Date: 18 May, 2010 16:28:48

Message: 1 of 5

Hi htere
if I have a matrix as:
A=[55555555555555 333333333333333 5225252552525252 121421212121212111 58088808808880 8808085416010654]

it wil be shown in the matlab as:
A =

  1.0e+017 *

    0.0006 0.0033 0.0523 1.2142 0.0006 0.0881


my question is:
how can I show each value in the matrix as a numbers without a power?

Subject: show the whole numbers...how

From: Walter Roberson

Date: 18 May, 2010 16:34:30

Message: 2 of 5

alfann wrote:

> if I have a matrix as:
> A=[55555555555555 333333333333333 5225252552525252 121421212121212111 58088808808880 8808085416010654]
>
> it wil be shown in the matlab as:
> A =
>
> 1.0e+017 *
>
> 0.0006 0.0033 0.0523 1.2142 0.0006 0.0881
>
>
> my question is:
> how can I show each value in the matrix as a numbers without a power?


format long f

or possibly

format long g

Subject: show the whole numbers...how

From: Roger Stafford

Date: 19 May, 2010 01:33:03

Message: 3 of 5

alfann <alfann.net@hotmail.com> wrote in message <2099019815.181559.1274200158332.JavaMail.root@gallium.mathforum.org>...
> Hi htere
> if I have a matrix as:
> A=[55555555555555 333333333333333 5225252552525252 121421212121212111 58088808808880 8808085416010654]
>
> it wil be shown in the matlab as:
> A =
>
> 1.0e+017 *
>
> 0.0006 0.0033 0.0523 1.2142 0.0006 0.0881
>
>
> my question is:
> how can I show each value in the matrix as a numbers without a power?

  If you type fprintf(' %18.0f\n',A), you will get all six of the above integers printed out in full.

  Note however that the fourth one is not reproduced exactly because it cannot be precisely represented by a double precision floating point number when it is entered. If you were to convert the fourth number as you have written it above to binary form, there would be a 57 bit span between the leftmost 1 bit and the rightmost 1 bit. Double precision numbers are capable of storing only 53 such bits, so matlab has to round it off to a 53-bit span to store it. This happens when the number is first entered with the A assignment statement, not at print time. What you see with fprintf above is what you actually have residing in A.

Roger Stafford

Subject: show the whole numbers...how

From: James Tursa

Date: 19 May, 2010 01:47:04

Message: 4 of 5

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hsvf4f$ejo$1@fred.mathworks.com>...
>
> If you type fprintf(' %18.0f\n',A), you will get all six of the above integers printed out in full.
>
> Note however that the fourth one is not reproduced exactly because it cannot be precisely represented by a double precision floating point number when it is entered.

e.g., to see this you can use my num2strexact utility:

>> A = num2strexact([55555555555555 333333333333333 5225252552525252 121421212121212111 58088808808880 8808085416010654]')
A =
    '5.5555555555555e13'
    '3.33333333333333e14'
    '5.225252552525252e15'
    '1.21421212121212112e17'
    '5.808880880888e13'
    '8.808085416010654e15'

num2strexact can be found here:

http://www.mathworks.com/matlabcentral/fileexchange/22239-num2strexact-exact-version-of-num2str

James Tursa

Subject: show the whole numbers...how

From: us

Date: 19 May, 2010 07:06:04

Message: 5 of 5

alfann <alfann.net@hotmail.com> wrote in message <2099019815.181559.1274200158332.JavaMail.root@gallium.mathforum.org>...
> Hi htere
> if I have a matrix as:
> A=[55555555555555 333333333333333 5225252552525252 121421212121212111 58088808808880 8808085416010654]
>
> it wil be shown in the matlab as:
> A =
>
> 1.0e+017 *
>
> 0.0006 0.0033 0.0523 1.2142 0.0006 0.0881
>
>
> my question is:
> how can I show each value in the matrix as a numbers without a power?

a hint:
- if it's just for display purposes
- if you own the symb tbx

     help vpa;

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