Got Questions? Get Answers.
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:
how to modify the data precision?

Subject: how to modify the data precision?

From: Kuo-Hsien

Date: 26 Sep, 2011 23:42:28

Message: 1 of 2

Dear all,

I have a large dataset with 7 columns as below showed.

   1.0000000e+00 1.0000000e+00 1.9510000e+03 1.0000000e+00 -2.4000000e+00 -1.8800000e+01 1.1000000e-01
   2.0000000e+00 1.0000000e+00 1.9510000e+03 2.0000000e+00 3.9000000e+00 -1.0400000e+01 1.3000000e-01
   3.0000000e+00 1.0000000e+00 1.9510000e+03 3.0000000e+00 7.2000000e+00 5.0000000e-01 9.0000000e-01
 
How to modify them to a desired data precision as below showed?

1 1 1951 1 -2.400 -18.800 0.110
2 1 1951 2 3.900 -10.400 0.130
3 1 1951 3 7.200 0.500 0.900

Thanks so much!
Michael

Subject: how to modify the data precision?

From: dpb

Date: 27 Sep, 2011 00:07:14

Message: 2 of 2

On 9/26/2011 6:42 PM, Kuo-Hsien wrote:
> Dear all,
>
> I have a large dataset with 7 columns as below showed.
>
> 1.0000000e+00 1.0000000e+00 1.9510000e+03 1.0000000e+00 -2.4000000e+00
> -1.8800000e+01 1.1000000e-01
> 2.0000000e+00 1.0000000e+00 1.9510000e+03 2.0000000e+00 3.9000000e+00
> -1.0400000e+01 1.3000000e-01
> 3.0000000e+00 1.0000000e+00 1.9510000e+03 3.0000000e+00 7.2000000e+00
> 5.0000000e-01 9.0000000e-01
>
> How to modify them to a desired data precision as below showed?
> 1 1 1951 1 -2.400 -18.800 0.110
> 2 1 1951 2 3.900 -10.400 0.130
> 3 1 1951 3 7.200 0.500 0.900

look at

doc num2str % note second optional precision argument
doc sprintf % and friends

Or if you're wanting less precision in the workplace as the default
display (and NB this has nothing whatsoever to do w/ the actual
"precision" of the data, only with the display formatting) you might try

format short % see doc format for choices, of course

--

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