how to separate columns from txt file

Hi,
I have attached a txt file needed to be delimeter by 3 columns.
Txt file looks like this
Freq. V(n001)
2.00000000000000e+001 (6.52532088670673e+001dB,-8.99982757383219e+001°)
2.00461047615580e+001 (6.52332088670214e+001dB,-8.99982770536383e+001°)
Need the output to looks like this with delimeter
2.00000000000000e+001 6.52532088670673e+001 -8.99982757383219e+001°
Especially the third column must be in degree fromat.
I have tried this code
clc;
clear all;
c = readtable("r4.4u_db.txt",'Format','%f %*c %f %*s %*c %f %*s');
But the 3rd column is totataly different like this
20.0461047615580
20.1386333770361
20.2315890851980
20.3249738574139
Don't know why does it show like that.
And aslo suggest a method to convert the dB vaues to linear values
The output plot from txt should look like attached photo.
Could anyone please help me to resolev the issue?

 Risposta accettata

M = readmatrix('r4.4u_db.txt', 'TrimNonNumeric',true, 'Delimiter',{'\t',','})
M = 6178×3
20.0000 65.2532 -89.9983 20.0461 65.2332 -89.9983 20.0923 65.2132 -89.9983 20.1386 65.1932 -89.9983 20.1851 65.1732 -89.9983 20.2316 65.1532 -89.9983 20.2782 65.1332 -89.9983 20.3250 65.1132 -89.9983 20.3718 65.0932 -89.9983 20.4188 65.0732 -89.9983

Più risposte (2)

Try:
c = readtable("r4.4u_db.txt",'Format','%f %*c %f %*c%*c%*c %f %*c%*c');

1 Commento

What is your reference value to computing dB? Very easy to convert to linear.
Linear=10.^(c.Var2/10)*refValue;

Accedi per commentare.

Use the force, uh, er, detectImportOptions, @Venkatkumar M...
opt=detectImportOptions('r4.4u_db.txt','NumHeaderLines',1,'Delimiter',{',',\t}, ...
'ExpectedNumVariables',3,'TrimNonNumeric',1);
tM=readmatrix('r4.4u_db.txt',opt);
results in
>> whos tM
Name Size Bytes Class Attributes
tM 6178x3 148272 double
>> tM(1:10,:)
ans =
20.0000 65.2532 -89.9983
20.0461 65.2332 -89.9983
20.0923 65.2132 -89.9983
20.1386 65.1932 -89.9983
20.1851 65.1732 -89.9983
20.2316 65.1532 -89.9983
20.2782 65.1332 -89.9983
20.3250 65.1132 -89.9983
20.3718 65.0932 -89.9983
20.4188 65.0732 -89.9983
>>
as for the latter Q?, db2mag

Community Treasure Hunt

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

Start Hunting!

Translated by