2021年3月23日星期二

matlab to python convert a function

How would I convert this code from matlab to python?

Matlab:

function out = f(x)  x1 = x(1);  x2 = x(2);  out = [x1+2*x2-2;x1^2+4*x2^2-4];  

Python? fx = np.array([[x1+2x2-2], [x1^2+4x2^2-4]])

x1 and x2 are in a list? and the position?

I dont know if this is the right way to define a mathematical function in python. I also dont know what x1 and x2 are referring to in matlab when converted to python.

Thank you

https://stackoverflow.com/questions/66774950/matlab-to-python-convert-a-function March 24, 2021 at 12:51PM

没有评论:

发表评论