help-octave
[Top][All Lists]
Advanced

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

Re: sscanf


From: Dimitri Maziuk
Subject: Re: sscanf
Date: Fri, 16 Nov 2012 17:19:06 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121030 Thunderbird/10.0.10

On 11/16/2012 04:58 PM, Ben Abbott wrote:
...

I guess you're right: I haven't used C is so long I forgot that
precision only works on the output side of "%f".

> 
> Using Matlab ...
> 
> str = '   1 M   HE    2.140';
> [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.

fgetl() followed by strsplit() works for me. Gotta wonder about
"numerical computation" software where 4 = 5 (4 values scanned, 5 values
in the row).

-- 
Dimitri Maziuk
Programmer/sysadmin
BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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