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 Kommentar

Cedric
Cedric am 18 Aug. 2015
Bearbeitet: Cedric am 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

the cyclist
the cyclist am 18 Aug. 2015

0 Stimmen

Maybe you could call Python from MATLAB?

2 Kommentare

Aldo Leal Garcia
Aldo Leal Garcia am 18 Aug. 2015
How can I do that? I'm a newbie in MATLAB
the cyclist
the cyclist am 18 Aug. 2015
My answer has a link to the Mathworks documentation page, with guidance on how to do it.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 18 Aug. 2015

Kommentiert:

am 18 Aug. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by