MATLAB: In an assignment A(I) = B, the number of elements in B and

assignmenterrormemory_analysis

Hello,
I am acquiring some data from a series of log files. when i use one specific log file everything works. When i choose any other log, i get this error :
In an assignment A(I) = B, the number of elements in B and I must be the same. Error in ==> memory_analysis2 at 22 Reading(i) = fscanf(fid, '%d', 1);
It is really strange because with another log file the same code works just fine. anyone has any ideas or same experience on this???? Thank you in advance.

Best Answer

The shown lines fails, if FSCANF cannot read a value, e.g. if the end-of-file is reached or if the available data do not match the %d format. Better include a test:
temp = fscanf(fid, '%d', 1);
if length(temp) == 1
Reading(i) = temp;
else
error('cannot get value');
end
Related Question