开发者

Calling Python function from MATLAB [duplicate]

开发者 https://www.devze.com 2023-03-11 08:56 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Call Python function from MATLAB
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Call Python function from MATLAB

I need to call a Python function from a MATLAB environment. Is it possible?

Let's assume, I have the following Python code:

def squared(x):
    y = x * x
    return y

How do I call square开发者_开发百科d(3) from MATLAB workspace/code and get 9?


I have never done this before, so someone else will have to provide a 'real' answer, but I can offer this.

I often call the shell from MATLAB on my Linux machine, with an exclamation point, >>!{comm} So I suppose you could have a shell script that calls python and call the script from MATLAB.

wbg

0

精彩评论

暂无评论...
验证码 换一张
取 消