Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Strange nondeterministic issues when usingphase_plot withX,Y andX0 set #970

Closed
Assignees
murrayrm
@FeldrinH

Description

@FeldrinH

I am trying to draw a phase plot with both streamlines and a vector field. Using the inverted pendulum ODE fromhttps://python-control.readthedocs.io/en/latest/phaseplots.html, I put together the following script:

importnumpyasnpimportmatplotlib.pyplotaspltfromcontrol.phaseplotimportphase_plot# Define the ODEs for a damped (inverted) pendulumdefinvpend_ode(x,t,m=1.,l=1.,b=0.2,g=1):returnx[1],-b/m*x[1]+ (g*l/m)*np.sin(x[0])# Set up the figure the way we want it to lookplt.figure()plt.title('Inverted pendulum')# Outer trajectoriesphase_plot(invpend_ode,X=(-10,10,20),Y=(-10,10,20),X0=[[-2*np.pi,1.6], [-2*np.pi,0.5], [-1.8,2.1],        [-1,2.1], [4.2,2.1], [5,2.1],        [2*np.pi,-1.6], [2*np.pi,-0.5], [1.8,-2.1],        [1,-2.1], [-4.2,-2.1], [-5,-2.1]])plt.show()

I would have expected this to plot a simple vector field with a grid of 20*20 arrows and streamlines from the given inital conditions. Instead, each time I run this I get a different malformed plot, often with at least one axis somehow having arrows at values like 10^281. Various RuntimeWarnings about overflow are also sometimes printed in the console. Some examples of the plots I have gotten:

image
image
image
image
image

This does not seem like expected behaviour. What is going on here?

Tested on Windows 10 with Python 3.10.11, matplotlib 3.8.2 and control 0.9.4 from pip.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp