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 件のコメント

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

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2015 年 8 月 18 日

コメント済み:

2015 年 8 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by