How can I process line by line while also using iteration to find a group in the data?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I have a very large data file (.txt) and that's why I get 'Out of memory' error. I want to limit the memory by reading/ process the data line by line, but I am having dificulties with this.
My data looks something like this
1 0 0.0283709 0.00291316 0.000373098 -0.00332569 e- CB 1
1 0 0.0351616 0.00312706 0.000380735 -0.00359444 e- CB 1
1 0 0 0.00337517 0.000336677 -0.00385419 e- CB 2
1 0 0 0.00343182 0.000328684 -0.00391487 e- CB 2
I would like to select all the data that has the same number in row 9 and process the data and plot it and move on to the next number. So here in this case the first and second row will be read and processed and afterwards the iteration goes to 2 and the third and fourth column will be processed.
I looked up several things but it only reads one line of the data and processes it and not a group of the data.
If anyone has an idea how to solve this... thanks!
7 Comments
Guillaume
on 26 Jun 2018
the same number in row 9 Do you mean column 9?
the same number as what?
What does plotting a number mean?
What does will be read and processed mean?
Gabriella Tany
on 26 Jun 2018
Guillaume
on 26 Jun 2018
Can you attach a demo file? Does readtable really run out of memory parsing the file?
Note that data is a 1x9 cell array, so data(:, n) is the same as data(1, n) and the same as data(n). In addition, your cell2mat are a waste of time. The proper way to extract the content of a cell array is with {}. So all your cell2mat(data(:, n)) should be replaced by data{n}
KSSV
on 26 Jun 2018
How long is your file? What's is it's size?
Gabriella Tany
on 26 Jun 2018
Edited: Gabriella Tany
on 26 Jun 2018
Guillaume
on 26 Jun 2018
The best solution is to indeed use tall arrays as Stephen says. More details for the desired plots are required for us to tell you how to do it.
Are all the groups plotted on the same plot?
Gabriella Tany
on 26 Jun 2018
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!