Stan
Posts:
63
Registered:
6/18/12


Re: Extract numbers from table containing text and numbers
Posted:
Jan 31, 2013 10:35 PM


"Stan" wrote in message <kef9u8$seu$1@newscl01ah.mathworks.com>... > Hello, > > I am trying to extract 2 columns from a file with 425 header lines and then the following: > > Q (upperedge 0.1250E03 AmP )= 0.98880E02+ 0.28300E03 units/alpha/round > Q (upperedge 0.2500E03 AmP )= 0.19648E01+ 0.39412E03 units/alpha/round > Q (upperedge 0.3750E03 AmP )= 0.18384E01+ 0.38318E03 units/alpha/round > Q (upperedge 0.5000E03 AmP )= 0.17536E01+ 0.37040E03 units/alpha/round > Q (upperedge 0.6250E03 AmP )= 0.16064E01+ 0.36000E03 units/alpha/round > Q (upperedge 0.7500E03 AmP )= 0.15888E01+ 0.35954E03 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' '(upperedge' '0.1250E03' > > Question: > 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?
There is a typo. It should be: >> set_m{1}
ans =
'' 'Q' '(upperedge' '0.1250E03'

