![]() | |
![]() |
![]() ![]() ![]() ![]() |
![]() |
The ternary operator works just the same as that in C-language. The ternary operator is expressed by A ? B : C. Firstly A is evaluated, if it is true (non-zero) B is executed; otherwise C is executed. The next example is a graph which is incontinuous at x=0, y=exp(-x) for x>0, and y=exp(4*x) for x<=0.
![]() More complicated functions can be definced with this ternary operator. Here is an example of user-defined function which varies discontinuously along with the X values.
![]() This function gives 100 if the absolute value of X is less than 1, 50 for 1<=|X|<2, 20 for 2<=|X|<3, and 10 otherwise. The Y values are not continuos between those X regions, but gnuplot connects those discrete Y values by line. The set sample command makes those "connected parts" be as vertical as possible. |
Gnuplot has a reread and if commands. With those you can make a simple loop. The command reread re-reads the file again. When gnuplot finds this command in the control file, an endless-loop begins. To terminate the loop, use the if command, and you can determine the number of iteration. Let's make a simple animation by rotating a 3D plot. To rotate the drawing, change the view point angle from 0 to 360 with 5 degrees step. Firstly, make a "loop.plt" file whose content is as follows. This is a figure of function z=exp(-x*x)*erf(y).
An initial value of theta and the other setting are given outside the 'loop.plt' file. The endless loop begins when gnuplot reads the load "loot.plt" command. You can make an animated GIF with some tool, but usually you have to pay for it :-p
|
![]() | |
![]() |
![]() ![]() ![]() ![]() |
![]() |