extract data from a text data.

1 visualizzazione (ultimi 30 giorni)
Rica
Rica il 3 Lug 2013
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

Risposta accettata

bruno
bruno il 3 Lug 2013
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...

Più risposte (0)

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by