フィルターのクリア

How to use a Python file in Matlab?

3 ビュー (過去 30 日間)
rahul venkat karuparthi
rahul venkat karuparthi 2021 年 9 月 17 日
編集済み: Ravi Narasimhan 2021 年 9 月 18 日
I am trying to use a Python file containing lot of functions in Matlab. When i tried running it using system(python ' '), I am unable to run the file as i am using numpy in Python file. I am using Numpy to find roots() of a cubic equation. Is there any other way to find the roots without importing from Numpy or How will I be able to use Numpy in Matlab?
I am getting ModuleNotFoundError*

回答 (1 件)

Ravi Narasimhan
Ravi Narasimhan 2021 年 9 月 18 日
Matlab offers a roots function to compute roots of polynomial (help roots). Is there some reason that won't work for you?
  2 件のコメント
rahul venkat karuparthi
rahul venkat karuparthi 2021 年 9 月 18 日
Yes, but, roots() is used in Python importing from Numpy. So, I am getting NoModuleError when I use that Python fie in Matlab.
In Matlab itself, roots() work like you said.
Ravi Narasimhan
Ravi Narasimhan 2021 年 9 月 18 日
編集済み: Ravi Narasimhan 2021 年 9 月 18 日
Do you have numpy in your Python distribution? Does your Python code work if you invoke it outside of Matlab?
An alternate approach is to use Matlab to read in your Python file, extract the polynomial coefficients, and use Matlab's roots() function.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by