I have been trying to read some numbers from formatted text file. I want to keep some number of columns from numerous columns, and I want to repeat it to the end of file (multiple rows or lines).
This is the code that I wrote to do that but it only reads one single line of the data.
fid = fopen ('L0512164529','r+');
num_ints = 47;
num_rows = 50;
features = struct;
format =['L%d,',repmat('%f,' , 1 , num_ints-1),'%f'];
[r_dat,l] = textscan(fid, format, num_rows);
features.name=r_dat{1};
features.bodyposfeat=[r_dat{2:end}];
fclose(fid);
Every line starts with a number with starting L. The first two rows of the file are:
L0512164529,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.1376599,-0.4387758,0.4723490,0.7519389,0.4742642,-0.8703301
L0512164529,0.0001816,0.0000005,-0.0005697,-1.0843741,0.0001816,0.0000005,-0.0005697,-1.0843741,0.1433973
fid = fopen(file), then use awhileloop:while ~feofdata(k,:) = fread(fid);k=k+1;end- Adriaan