Thanks a lot David, this is what I needed.

Just if somebody else might need it, i will resolve the problem:

# declare t and tau as symbolic variables
var('t')
var('tau')

# monoexponential equation
g(t) = e**(-t/tau)

# 2-piece result (one from 0 to t0, the second from t0 to 1000
t0 = 0.2 # this is the onset of the exponential function
MNTB_g  = piecewise([[(0,t0),lambda t:0],[(t0,1000),g.subs(tau=0.9)]])

# plots!
fig = list_plot([MNTB_g(t) for t in xrange(1000)], plotjoined = True, rgbcolor='red')
fig.show(xmax=25)

The figure looks a little weird though, I guess I would have to solve it analytically.

Thanks a lot for your help

Jose.

David Joyner wrote:
Use Piecewise. Type Piecewise? For examples.


On Tuesday, March 16, 2010, Jose Guzman <n...@neurohost.org> wrote:
Hi everybody,

i was wondering, which is the best method to plot a conditional function within 
an interval. For example, a function whose values are:

0 if t<t0
f(t) if t>t0

where f(t) is a simple monoexponential decay that starts at t0. I tried the 
following in Sage:

t = var('t')

def f(t,t0):
    if t<t0:
       return 0
   else:
       return e**(-(t)/tau)

Now if I plot

plot(f(t,t0=0.5,tau=0.05,0,1,rgbcolor='red')

The plot starts at t=0 and unfortunately the function f(t) too!

Is there any better way to define a conditional function with Sage?

Thanks a lot in advance.

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



--
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