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 Comment

Cedric
Cedric on 18 Aug 2015
Edited: Cedric on 18 Aug 2015
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.

Sign in to comment.

Answers (1)

the cyclist
the cyclist on 18 Aug 2015

0 votes

Maybe you could call Python from MATLAB?

2 Comments

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.

Sign in to comment.

Categories

Asked:

on 18 Aug 2015

Commented:

on 18 Aug 2015

Community Treasure Hunt

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

Start Hunting!