From Python to MATLAB

I have the next code in Pyhton, could anybody help me to tranform this code into MATLBA language in order to continuing using it PLEASE?
import np_plots as npp
import matplotlib.pyplot as plt
import numpy as np
import math as m
import scipy
from scipy.integrate import odeint
def plotLimitCycle(bval):
rhs = lambda X, t: [-X[0]+X[1]*X[0]**2, bval - X[1]*X[0]**2]
xeq, yeq = bval, 1.0/bval
cyclerad = m.sqrt(1-bval)
nbh = min(cyclerad, 0.05)
IC = [xeq-nbh/5.0, yeq-nbh/5.0]
time_span = np.linspace(0,400,40000)
fig = plt.figure()
solution = odeint(rhs, IC, time_span)
X, Y = zip(*solution)
plt.plot(X, Y)
axes = plt.gca()
axXmin, axXmax = axes.get_xlim()
axYmin, axYmax = axes.get_ylim()
xmin = max(-15, axXmin)
xmax = min(15, axXmax)
ymin = max(-15, axYmin)
ymax = min(15, axYmax)
X,Y,U,V = npp.ezDomainQuiver2D([[xmin, xmax],[ymin, ymax]],[25,25],lambda X: rhs(X, 0),Normalize=True)
plt.quiver(X,Y,U,V)
plt.scatter([xeq],[yeq], color='red')
plt.xlim([xmin, xmax])
plt.ylim([ymin, ymax])
plt.axes().set_aspect('equal', 'datalim')
plt.show()

1 个评论

Cedric
Cedric 2015-8-18
编辑:Cedric 2015-8-18
Try to implement it step by step. Split it into simple blocks, and see how to perform similar tasks in MATLAB. There are plenty of examples online that will show you how to perform what is done in this function (I don't have this np_plots lib that you are using though). Here is one.

请先登录,再进行评论。

回答(1 个)

the cyclist
the cyclist 2015-8-18

0 个投票

Maybe you could call Python from MATLAB?

2 个评论

How can I do that? I'm a newbie in MATLAB
My answer has a link to the Mathworks documentation page, with guidance on how to do it.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by