- #1

- 2,063

- 2

Could someone tell me how to plot step functions from the command line, just like you would the usual functions? Specifically, I'd like to plot floor/greatest integer functions.

Thanks

- Thread starter neutrino
- Start date

- #1

- 2,063

- 2

Could someone tell me how to plot step functions from the command line, just like you would the usual functions? Specifically, I'd like to plot floor/greatest integer functions.

Thanks

- #2

- 5,757

- 1,052

plot [-5:5][-5:5] ceil(x**2)

Your examples seem to require external data files.

- #3

- 2,063

- 2

Thanks a lot, robphy! :-)

plot [-5:5][-5:5] ceil(x**2)

Your examples seem to require external data files.

EDIT: I just tried an example. While it does plot the lines of constancy, there are slanted lines that "connect" the horizontal ones. Is there a way I could get rid of them, i.e., the slanted ones?

Last edited:

- #4

- 5,757

- 1,052

Try to increasing the sampling resolution before plotting:

set samples 10000

set samples 10000

- #5

- 2,063

- 2

Nice. Although the slants have only become vertical, they at least look like steps. Thanks, again. :)Try to increasing the sampling resolution before plotting:

set samples 10000

- #6

- 5,757

- 1,052

makes a suggestion to plot two piecewise-defined functions with illegal parts:

f1(x)=(x<1) ? 0 : sqrt(-1)

f2(x)=(x<1) ? sqrt(-1): 1

plot [-5:5][-2:2] f1(x),f2(x)

you'll have to poke around to set the color of each function to be the same

- #7

- 1

- 0

u(x,t)=(1+sgn(x-t))/2

- Replies
- 4

- Views
- 4K

- Last Post

- Replies
- 1

- Views
- 6K

- Replies
- 3

- Views
- 15K

- Replies
- 1

- Views
- 822

- Last Post

- Replies
- 3

- Views
- 15K

- Replies
- 3

- Views
- 4K

- Last Post

- Replies
- 1

- Views
- 2K

- Last Post

- Replies
- 0

- Views
- 11K

- Replies
- 0

- Views
- 829

- Last Post

- Replies
- 1

- Views
- 3K