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

1 view (last 30 days)
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.

Accepted Answer

Jan
Jan on 15 Aug 2011
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
  1 Comment
van lef
van lef on 15 Aug 2011
I tried opening the log file with notepad++ and i saw that the last line was empty but was being counted as a line( propably the eof or something) so when i deleted that everything went fine.....

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!