float & strip in array from Python to Matlab?

1 回表示 (過去 30 日間)
Adam Agus Kurniawan
Adam Agus Kurniawan 2020 年 6 月 29 日
コメント済み: Ameer Hamza 2020 年 6 月 29 日
I had this file "koefisienPolynomialSpectrumPenuh.txt" that contains alot of values on each rows. Now, I want to use this Python code and convert it to the Matlab.
teks = textread('koefisienPolynomialSpectrumPenuh.txt');
Python :
a0 = float(teks[0][6:13].strip())
a1 = float(teks[0][17:26].strip())
a2 = float(teks[0][27:39].strip())
a3 = float(teks[0][40:52].strip())
a4 = float(teks[0][54:].strip())
print a0, a1, a2, a3, a4
The result : 103.686 0.072558 -1.27386e-05 -1.01114e-10 2.53449e-14
  1 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 6 月 29 日
I don't have R2017a, but on R2020a, textread() automatically loads the data in numeric format. The value of the first row can be seen using
disp(teks(1,:))
Alternatively, you may also try
teks = load('koefisienPolynomialSpectrumPenuh.txt');

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by