How do I pull the specific data I need from a text file?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have an output file from which I am trying to pull specific data and plot it. I added comments in the format "% FIRST LINE OF X VALUES" to the file for the sake of people looking at my question being able to see which values I am trying to pull, however these comments are not in the actual output file. I am trying to pull two specific blocks of values from this file, one of "x" values and one of "y" values, and plot them and while I know how to plot the data once I've extracted it, I am not sure how to pull the data correctly from the file. For those trying to help, the data I need to pull is near the end of the attached file. Any ideas are greatly appreciated!
0 Commenti
Risposte (1)
Harish Ramachandran
il 19 Feb 2018
You can probably write your own parser and go through each line until you stumble upon the 'x' and 'y' parameters. Collect the data in a vector and then proceed to plot the 'x' and 'y' values.
A sample line parser for the txt file.
file = fopen('mctan.txt');
line = fgetl(file);
for i=1:6
if any(line == 'x values')
disp("x values need to be stored")
elseif any(line == 'y values')
disp("y values need to be stored")
line = fgetl(file);
end
fclose(file);
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Import and Export in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!