Hi,
I am trying to read a text file having 11 headerlines at the beginning and 30 rows of numberical data (in 4 different columns). I want to skip l0 lines and read every other line. The code is as such: clc filename='sample4.txt'; StartLine=11; %to skip the headers
fclose('all'); fid1 = fopen(filename); if fid1 == -1 disp(' ') disp('Operation was unsuccessful - Check the filename')
for k=1:StartLine-1 tline=fgetl(fid1); end
k=1; while ~feof(fid1)
for i = 1:10
d = fgets(fid1);
if isempty(d)|| ~ischar(line), break,end
end
numline(1:4) = str2num(d);
R=numline(1);
Z=numline(2);
Y=numline(3);
X=numline(4);
end
fclose(fid1);
Now my problem is that when I run the code I get this message: Which is as I believe, is happening from the loop. ??? Error using ==> str2num Requires string or character array input.
Error in ==> G:\Simulation\trail_RLE.m On line 31 ==> numline(1:4) = str2num(d);
Can someone help me please show me how to terminate the loop when the code reaches the end of the file??
AA