how to separate columns from txt file
15 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Stephen23
on 17 Nov 2022
M = readmatrix('r4.4u_db.txt', 'TrimNonNumeric',true, 'Delimiter',{'\t',','})
0 Comments
More Answers (2)
David Hill
on 17 Nov 2022
Try:
c = readtable("r4.4u_db.txt",'Format','%f %*c %f %*c%*c%*c %f %*c%*c');
1 Comment
David Hill
on 17 Nov 2022
What is your reference value to computing dB? Very easy to convert to linear.
Linear=10.^(c.Var2/10)*refValue;
dpb
on 17 Nov 2022
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
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!