extract data from a text data.

1 回表示 (過去 30 日間)
Rica
Rica 2013 年 7 月 3 日
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 Center および File ExchangeData Import and Export についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by