I imagine you are using something like sympy that is doing a mathematica
like plot over omega (the var statements)
In which case you need to change the line
x = linspace(0, 2pi)
to
omega = linspace(0, 2*w) # which seems to be the true range from the python
code, not 2pi
and then you need to change your
y = ...
bit to use elementwise multiplication (.*) and elementwise division (./) to
get the two arrays needed for the plot (omega, y) to be the same length.
On Tuesday, June 14, 2016 at 11:52:30 PM UTC-7, Henri Girard wrote:
> Hi,
>
> I would like to transform this python working example into a ijulia
> program ,
> Any help
> HG
>
> var("w")
> u=1/pi*360;s=1/(pi*360)
> R=100;L=10;C=10E-6
> w=1/(sqrt(L*C));var('omega')
>
> p=plot(abs(1/(1+i*omega*R*C-omega*omega*L*C)),omega,0,2*w,figsize=4,frame=True,
> fontsize=8,axes=False,color="green") ;show(p)
> print"Pulsation angulaire = ",round(w)," Rad/s"
>
> I tried this but got errors :
> R=100;L=10;C=10E-6;w=1/(sqrt(L*C));omega=0;
> x=linspace(0,2pi)
> y=(abs(1/(1+im*omega*R*C-omega*omega*L*C)));
> fig = figure("Angle")
> plt.plot(x, y);
> plt.ylabel("z");
> plt.xlabel("w");
> ax = plt.gca() # get current axes
> ax[:set_xlim]((0,2*w));
> ax[:set_ylim]((0,10));
> plt.grid("on")
> plt.title("Pulsation");
>
>
> LoadError: PyError (:PyObject_Call) <type 'exceptions.ValueError'>
> ValueError(u'x and y must have same first dimension',)
> File
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py",
> line 3154, in plot
> ret = ax.plot(*args, **kwargs)
> File
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.py",
> line 1812, in inner
> return func(ax, *args, **kwargs)
> File
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_axes.py",
> line 1424, in plot
> for line in self._get_lines(*args, **kwargs):
> File
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
> line 386, in _grab_next_args
> for seg in self._plot_args(remaining, kwargs):
> File
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
> line 364, in _plot_args
> x, y = self._xy_from_xy(x, y)
> File
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
> line 223, in _xy_from_xy
> raise ValueError("x and y must have same first dimension")
>
> while loading In[38], in expression starting on line 2
>
> [inlined code] from /home/pi/.julia/v0.4/PyCall/src/exception.jl:81
> in pycall at /home/pi/.julia/v0.4/PyCall/src/PyCall.jl:502
>
>
>