Effacer les filtres
Effacer les filtres

How do I pull the specific data I need from a text file?

3 vues (au cours des 30 derniers jours)
Jessica Maxson
Jessica Maxson le 16 Jan 2018
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!

Réponses (1)

Harish Ramachandran
Harish Ramachandran le 19 Fév 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);

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by