A very strange cell array size-relaetd issue
Show older comments
Hi!
I wrote a nice MATLAB program which reads information (numbers) stored in text files. This information is then presented graphically on the screen (as images or plots).
My problem is as follows: Everything works PERFECTLY for very small files (no bigger than 950kb) but not for larger files ???
The segment which performs the file loading, stores the data in a two dimentional (n by 30) array of cells. Each cell is a vector (normally consisting of 100 doubles):
datout = fopen('datout.txt');
i=0;
line = textscan(datout,'%s %d %s %f %s %s %f %s',1);
while ~feof(datout)
i=i+1;
handles.timestep_vector(i)=line{2};
handles.time_vector(i)=line{4};
handles.radius_vector(i)=(3/4/pi*line{7})^(1/3)/100000;
line = textscan(datout,'%s %s %s %s %s %s %s %s %s %s %s %s',1);
handles.A(i,1:11) = textscan(datout,'%*d %f %f %f %f %f %f %f %f %f %f %f',IMX);
line = textscan(datout,'%s %s %s %s %s %s %s %s %s %s %s %s',1);
handles.A(i,12:22)=textscan(datout,'%*d %f %f %f %f %f %f %f %f %f %f %f',IMX);
line = textscan(datout,'%s %s %s %s %s %s %s %s %s',1);
handles.A(i,23:30)=textscan(datout,'%*d %f %f %f %f %f %f %f %f',IMX);
line = textscan(datout,'%s %d %s %f %s %s %f %s',1);
end
fclose(datout);
Again, when using small files my program works impeccabley. When the size of array A is bigger than 21x30, I get the following error. Why?
??? In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in ==> PROG4>PROG4_OpeningFcn at 646 handles.timestep_vector(i)=line{2};
Error in ==> gui_mainfcn at 221 feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
Error in ==> PROG4 at 42 gui_mainfcn(gui_State, varargin{:});
The structure of the file DOES NOT change. And the maximum size allowed for an array is in the order of hundreds of MB... What is going on???
Accepted Answer
More Answers (1)
Jan
on 11 Oct 2011
0 votes
If the cell element line{2} is empty, you cannot assign it to handles.timestep_vector(i). I guess that you have an empty line ate the end of the file, or on of the data is missing.
Categories
Find more on Entering Commands 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!