Date: Jan 31, 2013 9:40 PM
Author: Stan
Subject: Extract numbers from table containing text and numbers


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 units/alpha/round
Q (upper-edge --0.3750E-03 AmP )= 0.18384E-01+- 0.38318E-03 units/alpha/round
Q (upper-edge --0.5000E-03 AmP )= 0.17536E-01+- 0.37040E-03 units/alpha/round
Q (upper-edge --0.6250E-03 AmP )= 0.16064E-01+- 0.36000E-03 units/alpha/round
Q (upper-edge --0.7500E-03 AmP )= 0.15888E-01+- 0.35954E-03 units/alpha/round

Here is my attempt, using textscan, and the output I am getting:

>> clear
>> clc
>> fid1=fopen('rqm7yxk1.out','rt');
>> 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 then read in the data
>> fclose(fid1);
>> set_m

set_m =

Columns 1 through 4

{1x4 cell} [0x1 double] {0x1 cell} [0x1 double]

Columns 5 through 7

{0x2 cell} [0x1 double] {0x1 cell}

>> set_m{1}

ans =

'' 'E' '(upper-edge' '--0.1250E-03'

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?