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:
numbers written in long format

Subject: numbers written in long format

From: Bilal

Date: 3 Nov, 2010 14:52:05

Message: 1 of 3

I'm writing to a file, after reading values from a device.
The problem i'm getting is the values in the array are written in a long format:

if the values are
-0.64
-0.16
....

They will be written to the text file as:
-6.400000e-001
-1.600000e-001
...

How can i have it write just as it was in the array i put it in?

Subject: numbers written in long format

From: Sean

Date: 3 Nov, 2010 14:59:05

Message: 2 of 3

"Bilal " <bilalhaider87@gmail.com> wrote in message <iarsul$38g$1@fred.mathworks.com>...
> I'm writing to a file, after reading values from a device.
> The problem i'm getting is the values in the array are written in a long format:
>
> if the values are
> -0.64
> -0.16
> ....
>
> They will be written to the text file as:
> -6.400000e-001
> -1.600000e-001
> ...
>
> How can i have it write just as it was in the array i put it in?

doc fprintf

Subject: numbers written in long format

From: Walter Roberson

Date: 3 Nov, 2010 17:48:00

Message: 3 of 3

On 10-11-03 09:52 AM, Bilal wrote:
> I'm writing to a file, after reading values from a device.
> The problem i'm getting is the values in the array are written in a long
> format:
>
> if the values are -0.64
> -0.16
> ....
>
> They will be written to the text file as:
> -6.400000e-001
> -1.600000e-001
> ...
>
> How can i have it write just as it was in the array i put it in?

The only general way to do this is to read the values as text from the device,
and to write the exact text out to the file. If the data is converted to
binary at any step, then it becomes impossible to determine whether what you
"put it in" to the array was -0.64 or -0.640 or -6.4E-1 (etc.)

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