Read comma delimited data from file with text

1 回表示 (過去 30 日間)
Caleb Alexander
Caleb Alexander 2015 年 3 月 31 日
コメント済み: per isakson 2015 年 3 月 31 日
Hi, I have a txt file that I'm trying to process. The file looks something like:
Init P/N = N
Scan Rate (V/s) = 0.005
Segment = 2
Sample Interval (V) = 0.001
Quiet Time (sec) = 2
Sensitivity (A/V) = 0.001
Segment 1:
Segment 2:
Potential/V, Current/A, Charge/C
Segment 1:
0.204, -1.725e-6, -3.451e-7
0.203, -1.161e-6, -5.772e-7
0.202, -8.960e-7, -7.564e-7
...
[hundreds of values in 3 columns]
<Empty line >
Segment 2:
-0.594, 4.877e-4, 3.714e-2
-0.593, 4.857e-4, 3.724e-2
-0.592, 4.853e-4, 3.734e-2
-0.591, 4.851e-4, 3.744e-2
[hundreds of values in 3 columns]
The first column is Potential, the second column is Current, and the third column is charge. I want to be able to take the Potential, Current, and Charge values in both Segment 1,2 and more for robustness as needed.
I've used fileread to get the contents of the txt file (i.e. text=fileread(filename)) and used strfind to find when 'Segment' occurs, but then I have no way of taking the data between Segment 1 and Segment 2 and separating it into something like dlmread,xlsread which need a filename. Also the number of data points for segment 1 is not necessarily the same as segment 2 so I'm also having trouble extracting the segment 2 data.
Any help extracting the segment 1 & segment 2 data, and assigning each column to a different variable say (Pot, Cur, Charge) would be most appreciated.
Thanks! Caleb

回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by