How to plot a circle in Matlab?

Don’t laugh, but the easiest would be to use the rectangle function, indeed 😉 %// radius r = 2; %// center c = [3 3]; pos = [c-r 2*r 2*r]; rectangle(‘Position’,pos,’Curvature’,[1 1]) axis equal but set the curvature of the rectangle to 1! The position vector defines the rectangle, the first two values x and … Read more

how to handle an asymptote/discontinuity with Matplotlib

By using masked arrays you can avoid plotting selected regions of a curve. To remove the singularity at x=2: import matplotlib.numerix.ma as M # for older versions, prior to .98 #import numpy.ma as M # for newer versions of matplotlib from pylab import * figure() xx = np.arange(-0.5,5.5,0.01) vals = 1/(xx-2) vals = M.array(vals) mvals … Read more

Safely evaluate simple string equation

One way would be to use numexpr. It’s mostly a module for optimizing (and multithreading) numpy operations but it can also handle mathematical python expressions: >>> import numexpr >>> numexpr.evaluate(‘2 + 4.1 * 3′) array(14.299999999999999) You can call .item on the result to get a python-like type: >>> numexpr.evaluate(’17 / 3′).item() 5.666666666666667 It’s a 3rd … Read more

Is it possible to plot implicit equations using Matplotlib?

I don’t believe there’s very good support for this, but you could try something like import matplotlib.pyplot from numpy import arange from numpy import meshgrid delta = 0.025 xrange = arange(-5.0, 20.0, delta) yrange = arange(-5.0, 20.0, delta) X, Y = meshgrid(xrange,yrange) # F is one side of the equation, G is the other F … Read more

Equation parsing in Python

Python’s own internal compiler can parse this, if you use Python notation. If your change the notation slightly, you’ll be happier. import compiler eq= “sin(x)*x**2” ast= compiler.parse( eq ) You get an abstract syntax tree that you can work with.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)