Velocity Reviews > Plot problem.. ?? No sign at all

# Plot problem.. ?? No sign at all

Ritchy lelis
Guest
Posts: n/a

 07-05-2010
hello guys..

I'm new at python programming and i'm having some problems with a
script that i have been developing for my final project of my

I have a script that is supposed to make a plot of a
"Residuo" (waveform) witch is an output of a ADC ( Analogic To Digital
Converter) for the first stage of the Flash pipiline ADC
structure.This script doesn't show any syntax errors but it doesn't
show no waveform at all at the plot window.

I am new to the Python language.

-----------------------------------------------------------------------

from pylab import*

Vref = arange(1, 20, 0.02)
Vi = arange(1, 10,0.1)

for i in Vref:
for n in Vi:
if n > i/4:
V0 = 2*n-i
elif (-i/4) <= n and n <= i/4:
V0 = 2*n
elif Vi < -i/4:
V0 = 2*n+i
else:
print "Try Again"
##print V0
plot (V0)boboz10

--------------------------------------------------------------------------------

MRAB
Guest
Posts: n/a

 07-05-2010
Ritchy lelis wrote:
> hello guys..
>
> I'm new at python programming and i'm having some problems with a
> script that i have been developing for my final project of my
>
> I have a script that is supposed to make a plot of a
> "Residuo" (waveform) witch is an output of a ADC ( Analogic To Digital
> Converter) for the first stage of the Flash pipiline ADC
> structure.This script doesn't show any syntax errors but it doesn't
> show no waveform at all at the plot window.
>
> I am new to the Python language.
>
>
> -----------------------------------------------------------------------
>
> from pylab import*
>
> Vref = arange(1, 20, 0.02)
> Vi = arange(1, 10,0.1)
>
> for i in Vref:
> for n in Vi:
> if n > i/4:
> V0 = 2*n-i
> elif (-i/4) <= n and n <= i/4:
> V0 = 2*n
> elif Vi < -i/4:
> V0 = 2*n+i
> else:
> print "Try Again"
> ##print V0
> plot (V0)boboz10
>
> --------------------------------------------------------------------------------
>

Only the first 2 'if' conditions are ever true, so nothing is ever
plotted.

Also, I don't know what you're trying to do here:

elif Vi < -i/4:

because Vi is an array and i is a float. If Python ever tried to execute
it there would be a ValueError exception:

ValueError: The truth value of an array with more than one element is
ambiguous.
Use a.any() or a.all()

Ritchy lelis
Guest
Posts: n/a

 07-06-2010
On 6 jul, 16:18, Alan G Isaac <(E-Mail Removed)> wrote:
> On 7/6/2010 8:05 AM, Ritchy lelis wrote:
>
> > *1 - "import numpy as np
> > * * * import matplotlib.pyplot as plt"

>
> > * * * In what help's me making the call's of the libraries that way?

>
> http://bytebaker.com/2008/07/30/python-namespaces/
>
> > *2 - What's the instruction linspace means/does?

>
> *>>> help(np.linspace)
> * * * * *Help on function linspace in module numpy.core.function_base:
>
> * * * * *linspace(start, stop, num=50, endpoint=True, retstep=False)
> * * * * * * *Return evenly spaced numbers over a specified interval.
>
> * * * * * * *Returns `num` evenly spaced samples, calculated over the
> * * * * * * *interval [`start`, `stop` ].
>
> > *3 - Last but more important: "V0 = ... #create an array" if I
> > *understood, there i'm supposed to introduce the for loop as in my
> > *initial example. correct?

>
> It is better to create your arrays without looping,
> if possible. *But create it however you wish.
> (Note than numpy arrays have a fixed length;
> create a Python list if you wish to append to it.)
>
> Cheers,
> Alan Isaac

-------------------------------------------------

My intention with de for loop was to iterate each point of the arrays
Vi and Vref at the math calculations. The V0 it's the result of the
math expressions between the Vi and Vref. I can't just create one V0
by a function set by parametters (i don't see how).

Could you give a clue?

Cheers

Ritchy

Ritchy lelis
Guest
Posts: n/a

 07-06-2010
On 6 jul, 17:29, Alan G Isaac <(E-Mail Removed)> wrote:
> On 7/6/2010 12:11 PM, Ritchy lelis wrote:
>
> > My intention with de for loop was to iterate each point of the arrays
> > Vi and Vref at the math calculations. The V0 it's the result of the
> > math expressions between the Vi and Vref. I can't just create one V0
> > by a function set by parametters (i don't see how).

>
> Unfortunately I cannot make sense of the code you posted.
> Provide a detailed description in words (or psuedocode)
> of what you are trying to accomplish. *Be very careful
> and detailed is you want a useful response.
>
> Alan Isaac

hummm...

ok, i will try to make that detailed description. Maybe i have not
been so clear because my inglish suck's
However i have a tutorial and another document that my teacher gave
me, i could send you it if you allowed me. It's the 2 best document's

Ritchy

Johan Grönqvist
Guest
Posts: n/a

 07-07-2010
2010-07-06 19:18, Ritchy lelis skrev:
> On 6 jul, 17:29, Alan G Isaac<(E-Mail Removed)> wrote:
>> Unfortunately I cannot make sense of the code you posted.
>> Provide a detailed description in words (or psuedocode)
>> of what you are trying to accomplish. Be very careful
>> and detailed is you want a useful response.
>>
>> Alan Isaac

>
> hummm...
>
> ok, i will try to make that detailed description.

I can tell you why I do not understand from your posted code what you
are trying to do.

Firstly, I do not understand if you are trying to plot a surface, a set
of curves, or a curve, or just a set of points? In your posted code, the
plot command is part of the else clause, and my guess is that you never
intend the else-clause to be executed at all.

In your code snippet you loop over two arrays (Vi and Vref), compute a
scalar value V0, and all plot-commands you issue are of the form
plot(V0). This will probably draw a line of one point (for each value in
Vi and Vref), which may not be what you want, and if it draws anything
at all, then all points will be drawn at the same x-value, which is also
probably not what you want.

Secondly, how are the Vi and Vref related to your axes? I assume you
want to plot all values you compute for V0, but as a function of what?
When I use the plot command, I usually give it (at least) two arguments,
where the first is the x-axis, and the second is the y-axis.

After I have understood those things, the next question would be about
the maths relating the Vi and Vref values to the V0 values, but I do not
think I will understand those until after the above points are explained
clearer.

I definitely think your english is not a problem here.

Johan

Ritchy lelis
Guest
Posts: n/a

 07-11-2010
On 7 jul, 08:38, Johan Grönqvist <(E-Mail Removed)> wrote:
> 2010-07-06 19:18, Ritchy lelis skrev:
>
> > On 6 jul, 17:29, Alan G Isaac<(E-Mail Removed)> *wrote:
> >> Unfortunately I cannot make sense of the code you posted.
> >> Provide a detailed description in words (or psuedocode)
> >> of what you are trying to accomplish. *Be very careful
> >> and detailed is you want a useful response.

>
> >> Alan Isaac

>
> > hummm...

>
> > ok, i will try to make that detailed description.

>
> I can tell you why I do not understand from your posted code what you
> are trying to do.
>
> Firstly, I do not understand if you are trying to plot a surface, a set
> of curves, or a curve, or just a set of points? In your posted code, the
> plot command is part of the else clause, and my guess is that you never
> intend the else-clause to be executed at all.
>
> In your code snippet you loop over two arrays (Vi and Vref), compute a
> scalar value V0, and all plot-commands you issue are of the form
> plot(V0). This will probably draw a line of one point (for each value in
> Vi and Vref), which may not be what you want, and if it draws anything
> at all, then all points will be drawn at the same x-value, which is also
> probably not what you want.
>
> Secondly, how are the Vi and Vref related to your axes? I assume you
> want to plot all values you compute for V0, but as a function of what?
> When I use the plot command, I usually give it (at least) two arguments,
> where the first is the x-axis, and the second is the y-axis.
>
> After I have understood those things, the next question would be about
> the maths relating the Vi and Vref values to the V0 values, but I do not
> think I will understand those until after the above points are explained
> clearer.
>
> I definitely think your english is not a problem here.
>
> Johan

hi Johan

Thanks for the interest in my problem... really appreciate.

About the plot draw it's a curve that it's a set of points wich it's
the result of the comput of the Vref and Vi together. I don't know if
i had to make a break instruction (like in other's languages) after
the "If" instructions if i want the else-condition to be executed? ...
(do you have some sujestions?)
Anyway i have a picture of a tuturial that i found but in this forum i
can't post it. That pic would show what a really want...

Relatively to the axis, the Vi takes the x-axis and the Vref takes the
y-axis.

As i said, i have a good 2 pic of a doc that has the information about

I would appreciate more of your help, if you permit me i could send
you those 2 pic and i guarantee that you would got the certain vision
of the problem.

I'll be waiting for your answer, i thing that you can help me.

Cheers.

Ritchy Lelis

Johan Grönqvist
Guest
Posts: n/a

 07-11-2010
2010-07-11 02:12, Ritchy lelis skrev:
> On 7 jul, 08:38, Johan Grönqvist<(E-Mail Removed)> wrote:
>
> About the plot draw it's a curve that it's a set of points wich it's
> the result of the comput of the Vref and Vi together. I don't know if
> i had to make a break instruction (like in other's languages) after
> the "If" instructions if i want the else-condition to be executed? ...
> (do you have some sujestions?)

I would have expected a code structure similar to this:

(NOTE: This is a very inefficient solution, and not the one suggested
earlier, but it is closer to the code snippet you posted originally, and
it does produce a plot.)

----------------------
import numpy as np
import matplotlib.pyplot as plt
Vref = np.linspace(1,20, 100)
Vi = np.linspace(1,10,100)

for ref in Vref: # Loop over Vref and Vi
for i in Vi:
if i > ref/4: # Compute V0
V0 = 2*i-ref
elif (-ref/4) <= ref and ref <= ref/4:
V0 = 2*i
elif i < -ref/4:
V0 = 2*i+ref
plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
plt.show() # Display the plot in a window
----------------------

> Anyway i have a picture of a tuturial that i found but in this forum i
> can't post it. That pic would show what a really want...

>
> Relatively to the axis, the Vi takes the x-axis and the Vref takes the
> y-axis.

To me this sound like you want to make a 3D-plot, as there is the
x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?

>
> As i said, i have a good 2 pic of a doc that has the information about
> this ADC that i'm developing.
>

I looked on wikipedia
<http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
figures. Is any of those similar to what you look for?

I see that they have (Vi - Vref) on the x-axis, and the computed value
on the y-axis.

Regards

Johan

Ritchy lelis
Guest
Posts: n/a

 07-11-2010
On 11 jul, 13:28, Johan Grönqvist <(E-Mail Removed)> wrote:
> 2010-07-11 02:12, Ritchy lelis skrev:
>
> > On 7 jul, 08:38, Johan Grönqvist<(E-Mail Removed)> *wrote:

>
> > About the plot draw it's a curve that it's a set of points wich it's
> > the result of the comput of the Vref and Vi together. I don't know if
> > i had to make a break instruction (like in other's languages) after
> > the "If" instructions if i want the else-condition to be executed? ...
> > (do you have some sujestions?)

>
> I would have expected a code structure similar to this:
>
> (NOTE: This is a very inefficient solution, and not the one suggested
> earlier, but it is closer to the code snippet you posted originally, and
> it does produce a plot.)
>
> ----------------------
> import numpy as np
> import matplotlib.pyplot as plt
> Vref = np.linspace(1,20, 100)
> Vi = np.linspace(1,10,100)
>
> for ref in Vref: # Loop over Vref and Vi
> * * *for i in Vi:
> * * * * *if *i > ref/4: # Compute V0
> * * * * * * *V0 = 2*i-ref
> * * * * *elif (-ref/4) <= ref and ref <= ref/4:
> * * * * * * *V0 = 2*i
> * * * * *elif i < -ref/4:
> * * * * * * *V0 = 2*i+ref
> * * * * *plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
> plt.show() # Display the plot in a window
> ----------------------
>
> > Anyway i have a picture of a tuturial that i found but in this forum i
> > can't post it. That pic would show what a really want...

>
> Can you give a link?
>
>
>
> > Relatively to the axis, the Vi takes the x-axis and the Vref takes the
> > y-axis.

>
> To me this sound like you want to make a 3D-plot, as there is the
> x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?
>
>
>
> > As i said, i have a good 2 pic of a doc that has the information about
> > this ADC that i'm developing.

>
> I looked on wikipedia
> <http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
> figures. Is any of those similar to what you look for?
>
> I see that they have (Vi - Vref) on the x-axis, and the computed value
> on the y-axis.
>
> Regards
>
> Johan

Hi

Yes those fig look's familiar to me but for now the objective its to
get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).

there are some fig and explanations on page's 9-13. Can you take a

Also you can take a look in http://www.maxim-ic.com/app-notes/index.mvp/id/1023

I'll be waiting for sujestions.

Thank's

Ritchy lelis
Guest
Posts: n/a

 07-13-2010
On 11 Jul, 17:39, Ritchy lelis <(E-Mail Removed)> wrote:
> On 11 jul, 13:28, Johan Grönqvist <(E-Mail Removed)> wrote:
>
>
>
>
>
> > 2010-07-11 02:12, Ritchy lelis skrev:

>
> > > On 7 jul, 08:38, Johan Grönqvist<(E-Mail Removed)> *wrote:

>
> > > About the plot draw it's a curve that it's a set of points wich it's
> > > the result of the comput of the Vref and Vi together. I don't know if
> > > i had to make a break instruction (like in other's languages) after
> > > the "If" instructions if i want the else-condition to be executed? ....
> > > (do you have some sujestions?)

>
> > I would have expected a code structure similar to this:

>
> > (NOTE: This is a very inefficient solution, and not the one suggested
> > earlier, but it is closer to the code snippet you posted originally, and
> > it does produce a plot.)

>
> > ----------------------
> > import numpy as np
> > import matplotlib.pyplot as plt
> > Vref = np.linspace(1,20, 100)
> > Vi = np.linspace(1,10,100)

>
> > for ref in Vref: # Loop over Vref and Vi
> > * * *for i in Vi:
> > * * * * *if *i > ref/4: # Compute V0
> > * * * * * * *V0 = 2*i-ref
> > * * * * *elif (-ref/4) <= ref and ref <= ref/4:
> > * * * * * * *V0 = 2*i
> > * * * * *elif i < -ref/4:
> > * * * * * * *V0 = 2*i+ref
> > * * * * *plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
> > plt.show() # Display the plot in a window
> > ----------------------

>
> > > Anyway i have a picture of a tuturial that i found but in this forum i
> > > can't post it. That pic would show what a really want...

>
> > Can you give a link?

>
> > > Relatively to the axis, the Vi takes the x-axis and the Vref takes the
> > > y-axis.

>
> > To me this sound like you want to make a 3D-plot, as there is the
> > x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?

>
> > > As i said, i have a good 2 pic of a doc that has the information about
> > > this ADC that i'm developing.

>
> > I looked on wikipedia
> > <http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
> > figures. Is any of those similar to what you look for?

>
> > I see that they have (Vi - Vref) on the x-axis, and the computed value
> > on the y-axis.

>
> > Regards

>
> > Johan

>
> Hi
>
> Yes those fig look's familiar to me but for now the objective its to
> get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).
>
> there are some fig and explanations on page's 9-13. Can you take a
>
> Also you can take a look inhttp://www.maxim-ic.com/app-notes/index.mvp/id/1023
>
> I'll be waiting for sujestions.
>
> Thank's- Ocultar texto citado -
>
> - Mostrar texto citado -

hi

This is how looks like the flash residue transference function that i

I'm suposed to obtain a figure like that in my plot.

Cheers

Ritchy lelis
Guest
Posts: n/a

 07-13-2010
On 11 Jul, 17:39, Ritchy lelis <(E-Mail Removed)> wrote:
> On 11 jul, 13:28, Johan Grönqvist <(E-Mail Removed)> wrote:
>
>
>
>
>
> > 2010-07-11 02:12, Ritchy lelis skrev:

>
> > > On 7 jul, 08:38, Johan Grönqvist<(E-Mail Removed)> *wrote:

>
> > > About the plot draw it's a curve that it's a set of points wich it's
> > > the result of the comput of the Vref and Vi together. I don't know if
> > > i had to make a break instruction (like in other's languages) after
> > > the "If" instructions if i want the else-condition to be executed? ....
> > > (do you have some sujestions?)

>
> > I would have expected a code structure similar to this:

>
> > (NOTE: This is a very inefficient solution, and not the one suggested
> > earlier, but it is closer to the code snippet you posted originally, and
> > it does produce a plot.)

>
> > ----------------------
> > import numpy as np
> > import matplotlib.pyplot as plt
> > Vref = np.linspace(1,20, 100)
> > Vi = np.linspace(1,10,100)

>
> > for ref in Vref: # Loop over Vref and Vi
> > * * *for i in Vi:
> > * * * * *if *i > ref/4: # Compute V0
> > * * * * * * *V0 = 2*i-ref
> > * * * * *elif (-ref/4) <= ref and ref <= ref/4:
> > * * * * * * *V0 = 2*i
> > * * * * *elif i < -ref/4:
> > * * * * * * *V0 = 2*i+ref
> > * * * * *plt.plot(i, V0, ".") # Plot one single point at x = i, y = V0
> > plt.show() # Display the plot in a window
> > ----------------------

>
> > > Anyway i have a picture of a tuturial that i found but in this forum i
> > > can't post it. That pic would show what a really want...

>
> > Can you give a link?

>
> > > Relatively to the axis, the Vi takes the x-axis and the Vref takes the
> > > y-axis.

>
> > To me this sound like you want to make a 3D-plot, as there is the
> > x-axis, the y-axis, and V0. Is this correct? Is V0 on a z-axis?

>
> > > As i said, i have a good 2 pic of a doc that has the information about
> > > this ADC that i'm developing.

>
> > I looked on wikipedia
> > <http://en.wikipedia.org/wiki/Analog-to-digital_converter>, and saw some
> > figures. Is any of those similar to what you look for?

>
> > I see that they have (Vi - Vref) on the x-axis, and the computed value
> > on the y-axis.

>
> > Regards

>
> > Johan

>
> Hi
>
> Yes those fig look's familiar to me but for now the objective its to
> get that residue transfer function (1.5-Bit-Per-Stage Pipelined ADC).
>
> there are some fig and explanations on page's 9-13. Can you take a
>
> Also you can take a look inhttp://www.maxim-ic.com/app-notes/index.mvp/id/1023
>
> I'll be waiting for sujestions.
>
> Thank's- Ocultar texto citado -
>
> - Mostrar texto citado -

hi

This is how looks like the flash residue transference function that i

I'm suposed to obtain a figure like that in my plot.

Cheers