On 27/04/12 21:55, Jason Grout wrote:
On 4/27/12 2:38 PM, Jose Guzman wrote:
On 27/04/12 20:52, Jason Grout wrote:
On 4/27/12 10:15 AM, Jose Guzman wrote:
Dear colleagues,

I am trying to manipulate an expression that starts at a time =
"tonset". Everything works nice until I try to plot.

#define independent variable
sage: t = var('t')

# define parameters
sage: taum, tauh = var('taum, tauh')
sage: tonset=var('tonset')

# normalize the equation
sage: f(t) = -e^(-t/taum)*(1-e^(-t/tauh))
sage: Tmax = solve(diff(f(t),t)==0,t)[0].rhs()
sage: norm_f(t) = (f(t-tonset) / f(Tmax))

Right here, aren't you shifting the plot of f to the right by tonset?
norm_f(t+tonset)=f((t+tonset)-tonset)/f(Tmax)=f(t)/f(Tmax), so that
norm_f(0+3)=f(0)/f(Tmax)? I think that horizontal shift may be the
problem?

Yes, this is exactly what I wanted; to have an offset, where the
function starts. Obviously, I want to plot between t=0 and a large t, so
that I can see where the onset begining.I find anyoing having to change
the axis, and I cannot get it with the Piecewise function

So do you just want norm_f(t)=f(t)/f(Tmax)?

I want a function that I can start at every tonset that i get:

f(t) =-e^(-(t-tonset)/taum)*(1-e^(-(t-tonset)/tauh))
Tmax = solve(diff(f(t),t)==0,t)[0].rhs()
norm(t) = f(t)/f(Tmax)

plot(epsc.subs(taum=0.3, tauh=5, tonset=3), 0+3, 5+3, figsize=[6,3])

Ideally, I would like to call the function plot with xmin=0 and
xmax=whatever.

Ah, I think I understand. Use the show command and specify the axis limits there. If you use the xmin/xmax commands inside the plot command, you can't tell the axes to start one place and the plotting to start another.

plot(norm_f.subs(taum=0.3, tauh=5, tonset=3), (t,0+3, 5+3)).show(xmin=0,xmax=10)

Wov, this is extremely useful. However, I wanted to get a function to have all values including the zeros. Now, I realized how to do it with Piecewise:

def biexp_norm(tonset):
h =piecewise([[(0, 3), lambda x :0],[(tonset, 10),g.subs(taum=0.3, tauh=5)(t-tonset)]])
    return(h)

You can see my example here: http://aleph.sagemath.org/?q=cb61e4be-15d6-4d98-b773-07a6cb334185

I have only to figure out how to __add__ different piecewise objects to have the sumation function.


See http://aleph.sagemath.org/?q=c42287ee-a155-4c90-b09e-d1a0c083fd44 for some more examples.

Amazing to have a single cell evaluation to share with other people!

Thanks a lot

Jose

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to