フィルターのクリア

how to read txt file with delimeter

3 ビュー (過去 30 日間)
Venkatkumar M
Venkatkumar M 2021 年 1 月 5 日
編集済み: Cris LaPierre 2022 年 11 月 17 日
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?

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 1 月 5 日
See this page: Import Text Files
  8 件のコメント
Cris LaPierre
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
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)
r4 = 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
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 ExchangeText Files についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by