Ask Your Question
1

stair function - how to

asked 2013-10-18 01:33:42 -0500

mresimulator gravatar image

Hi experts!

How can I make a stair function graph?

Thanks a lot!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-10-18 03:00:27 -0500

tmonteil gravatar image

I am not sure to understand your wish, do you mean something like:

sage: plot(floor, 0, 10)
edit flag offensive delete link more
0

answered 2013-10-18 02:22:24 -0500

calc314 gravatar image

You can use a sum of heaviside functions.

f(x)=heaviside(x)+heaviside(x-1)+heaviside(x-2)+heaviside(x-3)
plot(f(x),(x,0,4),exclude=[0,1,2,3])

Or, you can do it with a python function.

def step(x):
    if (0<x) and (x<1):
        return(1)
    elif (x<2):
        return(2)
    elif (x<3):
        return(3)
    else:
        return(4)
plot(lambda x: step(x),(x,0,4),exclude=[0,1,2,3])

You could also use the piecewise command.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-10-18 01:33:42 -0500

Seen: 291 times

Last updated: Oct 18 '13