matlab load python scripts have different result when directly run in python
古いコメントを表示
I load a python user-defined scripts in Matlab but I got different results with Python.
In python, I have a function to calculate the numerical intergral of an intergral function.
In matlab load this python scripts by:
system('python Userdefined.py');
A = py.Userdefined.Intergral(0.2);
But here 'A' is different with python result when I directly run 'Intergral(0.2)' in python.
I have confirmed that, Matlab result is wrong but I don't know why!
I just load it in Matlab.
5 件のコメント
KOU DU
2021 年 1 月 14 日
the cyclist
2021 年 1 月 15 日
Are you able to upload the script? I don't see how to help without it.
Mohammad Sami
2021 年 1 月 15 日
what is the purpose of the system command you issue before calling the function ?
KOU DU
2021 年 1 月 15 日
Ishan
2022 年 10 月 28 日

A call to the surfacearea_np with 0.2 as input gave an output of 1.7310113613083917 which is what MATLAB also gives. Essentially MATLAB just creates a call to the given function in the file you named 'Integral.py'. Do make sure you are calling the same function in your python script. Hope this helps!
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!