matlab - How to import column of numbers from mixed string numerical text file -


variations of question have been asked several times, example here. however, can't seem work data.

i have text file 3 columns. first , third columns floating point numbers. middle column strings. i'm interested in getting first column really.

here's tried:

filename=fopen('heartbeatn1nn.txt'); = textscan(filename,'%f','headerlines',0); fclose(filename); 

when comes out single number--the first element in column. how whole column? i've tried '.tsv' file extension, same result.

also tried:

filename=fopen('heartbeatn1nn.txt'); formatspec='%f';sizea=[1 inf]; = fscanf(filename,formatspec,sizea); fclose(filename); 

with same result.

could file size problem? not sure how many rows quite few since file size 1.7m.

assuming columns in text file separated single whitespace characters format specification should this:

a = textscan(filename,'%f %s %f'); 

a contains complete file content. obtain first column:

first_col = a{:,1}; 

alternatively, can tell textscan skip unneeded fields * option:

first_col = cell2mat( textscan(filename, '%f %*s %*f') ); 

this returns first column.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -