plotting discontinuous functions

plotting discontinuous functions

Post by Alec Himwi » Fri, 25 Jul 2003 05:36:48



Greetings

I want to plot a function that is only defined on disjoint subsets of
the x-axis.  It is easy enough for me to write such functions on
paper, e.g.,

f(x)= 1 for [0,.5], [1.1,2], [2.3,4.1]
    = undefined elsewhere

but it is not clear to me how to use gnuplot's syntax to plot the
function defined above.

Any help or suggestions would be appreciated.

Thanks in advance,

Alec Himwich

 
 
 

plotting discontinuous functions

Post by Hans-Bernhard Broeke » Fri, 25 Jul 2003 18:48:45



> Greetings
> I want to plot a function that is only defined on disjoint subsets of
> the x-axis.  It is easy enough for me to write such functions on
> paper, e.g.,
> f(x)= 1 for [0,.5], [1.1,2], [2.3,4.1]
>     = undefined elsewhere

You need two main ingredients to be able to do this:

1) the "decision-making operator", which gnuplot inherited from C:

        (x >=0 && x <= 0.5) ? one_value : other value

2) how to tell gnuplot a function's value is undefined:

        undefined = 0/0

Using these two, you can define some convenience functions that help doing
this kind of thing:

        inrange(x,a,b) = (x >= a && x <= b) ? 1 : undefined

        f(x) = 1 * inrange(x, 0, .5) + 1 * inrange(x, 1.1, 2)  \
               + 1*inrange(x, 2.3, 4.1)
--

Even if all the snow were burnt, ashes would remain.

 
 
 

1. Plotting a discontinuous curve?

Hello,

I would like to plot an approximation of a function with piecewise
smooth splines.  This approximation can be discontinuous, so I would
like to have the possibility of drawing a discontinuous curve
consisting of small continuous pieces.  Is this possible with Gnuplot?
At the moment I'm using version 3.7, where I did not find anything
like that in the manual.

Thank you, Nicolas.

2. 3D graphs

3. Lightwave, vertexmap, and Discontinuous UV-Map

4. how can i draw vectical text?

5. *Forcing* discontinuous UV's in 6.5?

6. Win Tv and Video Blaster Cards

7. contour plotting complex-valued functions

8. So WHEN will we see Mac LW?

9. NEWBIE: function plot in POVRAY

10. Newbie Question: plotting 3d functions in pov-ray

11. 3d function plotting program

12. help for function plotting

13. 3-d Function Plots