dpb
Posts:
6,677
Registered:
6/7/07
|
|
Re: Extract numbers from table containing text and numbers
Posted:
Feb 1, 2013 1:44 PM
|
|
On 1/31/2013 8:40 PM, Stan wrote: > Hello, > > I am trying to extract 2 columns from a file with 425 header lines and > then the following: > > Q (upper-edge --0.1250E-03 AmP )= 0.98880E-02+- 0.28300E-03 > units/alpha/round > Q (upper-edge --0.2500E-03 AmP )= 0.19648E-01+- 0.39412E-03 ...
> Here is my attempt, using textscan, and the output I am getting: > ...
>>> fmt1=[' %s' '%s' '%s%s%f' '%s' '%s' ' %f%s%s' ' %f' '%s']; >>> set_m=textscan(fid1, fmt1,'delimiter',' >>> ','headerlines',425,'CollectOutput',true); %skip 425 header lines and ... > I need the 3 columns that contain the numbers. Only the first 4 columns > seem to be working. Is there something that I am missing, in the > formatting, for the remaining columns?
Yeah, the numbers are ill-formed w/ the doubled signs methinks...since you have a fixed format I'd use string-matching...
I cut'n pasted a sample line into a cell string and at the command line get...
>> textscan(d{1},'Q (upper-edge -%f AmP )= %f+- %f %*s') ans = [-1.2500e-04] [0.0099] [2.8300e-04] >>
Salt to suit...
--
|
|