Loading a large text file into MATLAB
geodave
Arizona
Hello everyone,
I have a question about loading a large (~100 Mb) 3-column, space-delimited text file into the MATLAB workspace. Here's what I've tried so far:
(1) Using the "load" command. There's a noticeable delay time here (~1 min) considering I'm running a 6 Gb RAM, 2.4 GHz laptop (which is probably a slug compared to what you guys have, but it's all I can afford at the moment! ).
(2) Using the "textscan" command as follows:
Any suggestions or ideas would be much appreciated!
geodave
I have a question about loading a large (~100 Mb) 3-column, space-delimited text file into the MATLAB workspace. Here's what I've tried so far:
(1) Using the "load" command. There's a noticeable delay time here (~1 min) considering I'm running a 6 Gb RAM, 2.4 GHz laptop (which is probably a slug compared to what you guys have, but it's all I can afford at the moment! ).
(2) Using the "textscan" command as follows:
>> fid = fopen('very_large_text_file.txt'); >> data = textscan(fid, '%f %f %f', 'delimiter', ' ');Option (2) above appears to be efficient (takes a couple of seconds to complete on my laptop). However, when I try to plot one column against another using "plot" as follows:
figure(1); plot(data(:,1), data(:,2), 'k.');I get the following error:
??? Error using ==> plot Conversion to double from cell is not possible.Now, I'm not very familiar with cell arrays, so I'm blaming this error on my lack of MATLABing skills. And so I turn to you guys. Any ideas or suggestions as to how I can plot one column against the other after loading the text file using "textscan", or perhaps converting the cell array to a regular array (if at all possible)?
Any suggestions or ideas would be much appreciated!
geodave
0
Comments
(1) Used the textscan command I mentioned above to read the large text file.
(2) Assigned the columns as follows: (3) Plotted x vs. y as follows: Cheers,
geodave