How can I import text and data from a .txt file?
Show older comments
The format of the file is two column, with headers "Masses" and "Intensities"
However, those headers are rewritten after each scan, so the file looks like this:
Masses Intensities
10.0 1.2131233e7
11.0 3.13214e5
12.0 2.234234e7
Masses Intensities
10.0 2.2314324e7
11.0 4.12123123e5
12.0 1.921393e7
Masses Intensities
...
and so on.
When I use a command like
A = importdata('C:\Users\gps9h\Dropbox\MBMS\data\2015_8_24\2015_8_24_Run_2_chro.txt','\t'); % code
I get a structure A which has all of the data from the first scan, and also has the headers, which is good. But how do I get it to extract the data from all of the scans? (ie not to stop after it comes across the words 'Masses' and 'Intensities' for the second time?
I played around with fscanf and load commands and nothing was doing quite what I wanted. The IDEAL would be to make a 3-d array where I have scans 1-N, and then a column of masses and a column of intensities for each scan.
Thanks so much! This is my first time using matlab forum so let me know if anything is out of line in how I ask the question or if this has been answered elsewhere.
Accepted Answer
More Answers (0)
Categories
Find more on Large Files and Big Data 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!