How to run a user input MATLAB function in Python

조회 수: 4 (최근 30일)
Mohd Shihabuddin Khan
Mohd Shihabuddin Khan 2019년 10월 2일
답변: Shishir Singhal 2020년 4월 6일
Hi
Based on the example given in the documentation, we can call a MATLAB file
triarea.m
from a python script as follows:
import matlab.engine
eng = matlab.engine.start_matlab()
eng.triarea(nargout=0)
What if, we had a variable in Python with the MATLAB filename input by the user,
file_name = 'triarea'
then,
eng.file_name(nargout=0)
returns the error
MatlabExecutionError: Undefined function 'file_name' for input arguments of type 'double'.
How can we run the user input MATLAB function in Python?
In my actual problem, the file_name is input while instantiating an object of a class and is stored as an object attribute. Then one of the methods of the object calls this MATLAB file.

답변 (1개)

Shishir Singhal
Shishir Singhal 2020년 4월 6일

카테고리

Help CenterFile Exchange에서 Call MATLAB from Python에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by