Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting some piecewise functions in gnuplot

Tags:

gnuplot

Could you please tell me how can I plot functions that looks like:

f(x)=(x-1)^2 for 0 < x < 1 
f(x)=(x-8)^2 for 1<=x<=7
f(x)=x for x>7

in gnuplot. (If you could tell how to call such a kind of function in English I try to change the topic to the more appropiate).

like image 952
Wojciech Reszelewski Avatar asked Aug 24 '26 07:08

Wojciech Reszelewski


1 Answers

You can do it in that way:

f(x)=x<=1 ? -(x-1)**2+1 :  x>7 ? (-48)*sin(240)+1+0.5*x : (-(x-1)**2+1)*sin(30*x)+1
plot f(x)
like image 56
Wojciech Reszelewski Avatar answered Aug 27 '26 00:08

Wojciech Reszelewski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!