Normalizing the E descriptor
Show older comments
I've created data files with Matlab using the E descriptor for the number format. This produces output of the form:
-1.0345359317572725e-002
1.0802940928336107e+000
However, a Fortran90 based code in which I need to load the data can't interpret this format. It expects to see numbers that are "Normalized," that is, the number is shifted over so that the first digit is in the tenths position. A leading zero and decimal are always present and a minus sign, if needed. For example, our above numbers need to be in the form:
-0.10345359317572725e-001
0.10802940928336107e+001
I've been trying to get the data into this format and have managed to do so in a script by converting the numbers to strings, doing the logic, and returning a cell of strings. However I am unable to write this data to a file without losing my format. Is there a simpler way to normalize the number format? Is there a way to write a cell array of strings to a regular file?
Accepted Answer
More Answers (1)
Walter Roberson
on 13 Aug 2012
The normalization rule applies only to how output values are created, and does not apply to how input values must be presented.
Look at the standard at http://docs.oracle.com/cd/E19957-01/805-4939/z40007437a2e/index.html and search down to "E Editing" and from there look at the first example, which includes
CHARACTER L*40/'1234567E2 1234.67E-3 12.4567 '/
as a string that will be validly interpreted by an E format specifier. Notice the second number there includes an E exponent but is not normalized.
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!