2335
|
1 # Octave demo |
|
2 |
|
3 # This is not a function file. |
|
4 1; |
|
5 |
|
6 function demo_clear () |
|
7 clc (); |
|
8 endfunction |
|
9 |
|
10 function demo_set_term () |
|
11 term = getenv ("TERM"); |
|
12 display = getenv ("DISPLAY"); |
|
13 if (! strcmp (term, "xterm") || columns (display) == 0) |
|
14 graphics_terminal = input ("enter graphics terminal type: ", "s"); |
|
15 command = sprintf ("set term %s", graphics_terminal); |
|
16 eval (command); |
|
17 endif |
|
18 endfunction |
|
19 |
|
20 function demo_graphics () |
|
21 demo_clear (); |
|
22 demo_set_term () |
|
23 demo_clear (); |
|
24 printf ("Graphics\n"); |
|
25 fflush (stdout); |
|
26 sombrero (31); |
|
27 pause (10); |
|
28 printf ("press return to continue\n"); |
|
29 fflush (stdout); |
|
30 pause (); |
|
31 endfunction |
|
32 |
|
33 function demo_linear_algebra () |
|
34 demo_clear (); |
|
35 printf ("Solving Linear Algebra Problems\n"); |
|
36 fflush (stdout); |
|
37 pause (); |
|
38 endfunction |
|
39 |
|
40 function demo_odes () |
|
41 demo_clear (); |
|
42 printf ("Solving ODEs and DAEs\n"); |
|
43 fflush (stdout); |
|
44 pause (); |
|
45 endfunction |
|
46 |
|
47 while (1) |
|
48 |
|
49 demo_clear (); |
|
50 |
|
51 choice = menu ("Octave\n======\n\n", ... |
|
52 "Graphics", ... |
|
53 "Linear Algebra", ... |
|
54 "ODEs and DAEs", ... |
|
55 "Exit"); |
|
56 |
|
57 if (choice == 1) |
|
58 demo_graphics (); |
|
59 elseif (choice == 2) |
|
60 demo_linear_algebra (); |
|
61 elseif (choice == 3) |
|
62 demo_odes (); |
|
63 elseif (choice == 4) |
|
64 printf ("\nGoodbye and good luck!\n\n"); |
|
65 fflush (stdout); |
|
66 break; |
|
67 endif |
|
68 |
|
69 endwhile |