help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sscanf


From: Ben Abbott
Subject: Re: sscanf
Date: Fri, 16 Nov 2012 17:58:16 -0500

On Nov 16, 2012, at 5:44 PM, Dimitri Maziuk wrote:

> On 11/16/2012 04:37 PM, Ben Abbott wrote:
> 
>> The problem appears to be with the float.
>> 
>> [row, cnt, err] = sscanf (str, "%4d %1s %4s %8f")
>> row =
>> 
>>    1.0000
>>   77.0000
>>   72.0000
>>   69.0000
>>    2.1400
> 
> Yes, but why is it not returning
> 
>    1
>    "M"
>    "HE"
>    2.1400
> 
> ???
> 
> Anyway, the format string is read from the input file that I don't
> control (http://spin.niddk.nih.gov/NMRPipe/table/csObs.tab) so this is
> academic: if "8.3" doesn't work then sscanf() doesn't work as far as I'm
> concerned.

Using Matlab ...

str = '   1 M   HE    2.140';
[row, cnt, err] = sscanf (str, '%4d %1s %4s %8f');
[row, cnt, err] = sscanf (str, '%4d %1s %4s %8f')

row =

    1.0000
   77.0000
   72.0000
   69.0000
    2.1400


cnt =

     4


err =

     ''
So it appears the behavior is intended.  No doubt someone familiar with the 
sscanf() will educate us on what is happening.

Have you looked at textscan() or strread()?  Their behavior seems to be closer 
to what you're looking for.

Ben




reply via email to

[Prev in Thread] Current Thread [Next in Thread]