Filter löschen
Filter löschen

Pulling certain data from a text file into Matlab.

1 Ansicht (letzte 30 Tage)
BrieAnna Mosley
BrieAnna Mosley am 9 Jan. 2020
Beantwortet: Mateus Banroc am 9 Jan. 2020
I am trying to pull the frequence and the angle data only from this .txt file.
I have attached a sample of the data.

Antworten (1)

Mateus Banroc
Mateus Banroc am 9 Jan. 2020
Hi BrieAnna,
Consider using fgetl function to read the lines of txt. And also use strsplit to split the string and get the individual values you want.
strsplit returns a cell array, so remember to transform the cell element in string (letters) or double (numbers).
Ex:
fid = fopen('mytxt.txt');
line = fgetl(fid); % line = '0.000, 0.000, 0.000, 9.000'
line = strsplit(line,', '); % line = {'0.000'} {'0.000'} {'0.000'} {'9.000'}
freq = str2num(line{4}); % freq = 9.000
fclose(fid)

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by