Pulling certain data from a text file into Matlab.

조회 수: 19 (최근 30일)
BrieAnna Mosley
BrieAnna Mosley 2020년 1월 9일
답변: Mateus Banroc 2020년 1월 9일
I am trying to pull the frequence and the angle data only from this .txt file.
I have attached a sample of the data.

답변 (1개)

Mateus Banroc
Mateus Banroc 2020년 1월 9일
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)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by