Prev: OLS regression
Next: fmincon
From: alfann on
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?
From: Walter Roberson on
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
From: Roger Stafford on
alfann <alfann.net(a)hotmail.com> wrote in message <2099019815.181559.1274200158332.JavaMail.root(a)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
From: James Tursa on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hsvf4f$ejo$1(a)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
From: us on
alfann <alfann.net(a)hotmail.com> wrote in message <2099019815.181559.1274200158332.JavaMail.root(a)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
 | 
Pages: 1
Prev: OLS regression
Next: fmincon