I was able to reproduce your error as below:
A = str2num('')
B = str2num([])
The documentation for fgetl says that, after the last line of the file is reached, the result of the function is -1. Because this is already a number, you will not be able to transform it with str2num.
I notice that you are using feof to stop execution at the end of the text file. The issue is that you are using fgetl several times before MATLAB evaluates the while statement again.
while ( ~feof(fidd) )
tline = fgetl(fidd);
if
tline = fgetl(fidd);
while (isempty(str2num(tline)))
tline = fgetl(fidd);
i = i+1;
end
while(~isempty(str2num(tline)))
j=j+1;
tline = fgetl(fidd);
i = i+1;
von_S(j)=data_f(6);
end
end
end
MATLAB only checks the condition of the while loop at the beginning of each new loop.
For example,
X = true;
while X==true
X = false;
X = true;
end
Will run forever because X is always true when MATLAB checks.
You either need to call one line each time the first while loop starts or you need to add stops in other parts of the code. For example, adding
in each of your while loops should stop the program from executing after the end of the text file is reached.
However, you may prefer to reorganize your code as follows:
while ( ~feof(fidd) )
tline = fgetl(fidd);
if regexpi()
i=i+1;
if (~isempty(str2num(tline)))
j=j+1;
end
end
end
The program reads every line of the file (I have a hunch your previous program was skipping some lines) and then evaluates each one according to the same conditions as your program.
Finally, note that isempty gives the same results whether the array is numeric or characters. Because of this, there is no need for str2num in the conditions.