extract data from a text data.

2 次查看(过去 30 天)
Hi all!
i have a text file. it is constructed like this:
input start1
a:12 b:1.5 c:1.75 d:0.25
a:52 b:3.5 c:2.75 d:0.75
a:12 b:1.5 c:1.75 d:0.25
...
...
...
a:12 b:1.5 c:1.75 d:0.25
output end1
input start2
a:12 b:1.5 c:1.75 d:0.25
a:52 b:3.5 c:2.75 d:0.75
a:12 b:1.5 c:1.75 d:0.25
...
...
...
a:12 b:0 c:1.752 d:0.225
output end2
input start3
..
...
...
...
How could read this text file? imean i want just th parameter a b c d .
thank you

采纳的回答

bruno
bruno 2013-7-3
fid=fopen('file.txt','r');
text=textscan(fid,'a:%f b:%f c:%f d:%f \n');
fclose(fid);
text will be a 1*4 cell array, where text{1,1} is the vector of all your a, where text{1,2} is the vector of all your b...

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by