io format specifier question

Carlo de Falco carlo.defalco at gmail.com
Tue Jul 1 14:17:02 CDT 2008


On 01/lug/08, at 19:24, A. Kalten wrote:

> On Tue, 1 Jul 2008 20:02:36 +0200
> "marco restelli" <mrestelli at gmail.com> wrote:
>
>>   I need to read an ASCII file containing floating point numbers as
>>
>> 0.112977-141
>>
>> which stands for 0.112977E-141 (i.e., the E is omitted). The point  
>> is,
>> fscanf(fp,'%e') treats this as two numbers
>>
>
> If you're on a unix system, just do:
>
> sed s/-/e-/ file > file-new
>
> This will convert all "0.112977-141" to "0.112977e-141"
>
> AK

I am afraid that would mess up with negative numbers...
Try:

sed 's/\([0-9]*.[0-9]*\)\([-+]\)/\1e\2/' filename > newfilename

this asumes you have one number per row...
anyway, if it is easy to read this format in fortran, you can easily
wrap a small fortran program in a DLD function to call it from octave.

c.

P.S. Ciao Marco :)




More information about the Help-octave mailing list