How to pass Matlab to python?

Asked

Viewed 301 times

0

f0 = 20000;
a0 = 1;
alfa = 0;
T1 = f0/a0; 
sigma1 = T1*cos(deg2rad(alfa));
tau1 = T1*sin(deg2rad(alfa));
    for teta=0:1:180
          tau(teta+1) = (sigma1/2)*sin(deg2rad(2*teta));
          sigma(teta+1) = (sigma1/2)*(1+cos(deg2rad(2*teta)));
    end
plot(sigma,tau);
  • All trigonometric functions used are present in Python in the package Math. Take a look at the documentation that will easily understand how they work. For the creation of the chart, see the package matplotlib.

1 answer

0

To start the MATLAB® engine in a Python session, you must first install the engine API as a Python package. MATLAB provides a standard Python setup.py file to build and install the mechanism using the distutils module. You can use the same setup.py commands to create and install the engine on Windows®, Mac or Linux®systems.

Before installing, check Python and MATLAB settings.

Your system has a supported version of Python and MATLAB R2014b or later. To check that Python is installed on the system, run Python at the OS prompt.

Add the folder containing the Python interpreter to your path if it is not already there.

Find the path to the MATLAB folder. Start MATLAB and type matlabroot in the command window. Copy the path returned by matlabroot.

To install the engine API, run the following commands at the operating system prompt, where matlabroot is the path to the MATLAB folder. You may need administrator privileges to execute these commands. Alternatively, use one of the non-standard options described in Installing the MATLAB engine API for Python in non-standard locations.

On Windows systems -

cd "matlabroot extern Engines python" python setup.py installation On Mac or Linux systems -

cd "matlabroot / extern / Engines / python" python setup.py installation

This in the documentation: https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.