I have an equation which goes like this
f(x) = x*10 ; 0 < x <= 10
= x*x + x*10 ; 10 < x < 20
How do I plot f(x) in one graph using gnuplot?
I have an equation which goes like this
f(x) = x*10 ; 0 < x <= 10
= x*x + x*10 ; 10 < x < 20
How do I plot f(x) in one graph using gnuplot?
plot [0:20] x <= 10 ? x*10 : x*x + x*10
Update: if you have more than two functions, you can use this approach:
f(x) = x <= 10 ? x \
: x <= 20 ? x**2 \
: x <= 40 ? sqrt(x) \
: x**3
and afterwards,
plot [0:40] f(x)
To clarify, value f(x)
will be:
x
if x
is equal or less than 10x^2
if x
is greater than 10 and equal or less than 20x
if x
is greater than 20 and equal or less than 40x^3
if x
is greater than 40