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:
Need urgent help guys

Subject: Need urgent help guys

From: dhiraj

Date: 23 Feb, 2013 00:25:07

Message: 1 of 2

Hello
I am having a strange problem and thinking I can use MATLAB to solve it.
I have text files with content as below:
 7.9862668e+001 7.8140733e+001 8.0422936e+001 8.2806563e+001 8.3409122e+001 8.5673324e+001 8.7745376e+001 8.7303741e+001 8.5174770e+001 8.4144757e+001 8.3794223e+001 8.6131919e+001 8.7120891e+001 8.8307760e+001 8.8322351e+001 8.7581641e+001


What I want is to change the format of these numbers. For e.g. I want 7.9862668e+001 to change to 798.62 and so on for all the numbers.

Thank you in advance.

Subject: Need urgent help guys

From: Jan Simon

Date: 23 Feb, 2013 00:45:08

Message: 2 of 2

Dear dhiraj,

Read the file using:
  V = fscanf(fid, '%g ');
Write the new file:
  fprintf(fid, '%.2f ', V);

Kind regards, Jan

Tags for this Thread

No tags are associated with 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