how to read txt file with delimeter
1 次查看(过去 30 天)
显示 更早的评论
Hey guys i have read particular data from text file with header shown below
Freq. V(x)
0.00000000000000e+000 (3.28243072429145e+000dB,0.00000000000000e+000°)
1.00000000000000e+000 (-6.45914961580970e+000dB,-1.65794548852105e+000°)
I want the read this data alone and negelect remaining datas
0.00000000000000e+000 3.28243072429145e+000dB
1.00000000000000e+000 -6.45914961580970e+000dB
could anyone please assist me on this?
0 个评论
采纳的回答
Cris LaPierre
2021-1-5
See this page: Import Text Files
8 个评论
Cris LaPierre
2022-11-2
编辑:Cris LaPierre
2022-11-2
Did you take into consideration that this data set has 3 columns? Please share the code you have tried.
The only way to include the units is to read in the number and unit as a string. I find storing numbers as strings to not be very useful.
Cris LaPierre
2022-11-17
编辑:Cris LaPierre
2022-11-17
EDIT: The post I responded to was removed. Here is a screenshot
I discovered a simpler way. Try this.
file = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1196783/r4.4u_db.txt';
r4 = readmatrix(file,'Delimiter',["\t",","],'TrimNonNumeric',true)
For converting db to linear, consider using the db2mag function (requires the Control Systems Toolbox).
tiledlayout(2,1)
nexttile
semilogx(r4(:,1),db2mag(r4(:,2)))
grid on
nexttile
semilogx(r4(:,1),r4(:,3))
grid on
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!