3.5 Visualisation of a Wave Using SciLab
23
SciLab can be used to write short simulation codes. Larger model codes, however, would take too long to run in SciLab and the preference in these cases should
be FORTRAN. Specifi SciLab plotting commands are explained in due course of
this book.
3.5.5 The First GIF Animation
To produce a GIF animation watchable in most Web browsers, each picture frame
produced in the SciLab script needs to be converted to an individual numbered GIF
image. To this end, the script needs two additions. The following line needs to be
added directly after the start of the animation loop:
scf(0); //set ID for graphic window
This allocates an identificatio number (0 here) to the graphics window. Within
the animation loop, content of the graphics window can then be converted to a GIF
fil with:
if n < 10 then // n is the loop counter
xs2gif(0,‘MyFirst100’+string(n)+‘.gif’)
else
if n < 100 then
xs2gif(0,‘MyFirst10’+string(n)+‘.gif’)
else
xs2gif(0,‘MyFirst1’+string(n)+‘.gif’)
end
end
The “string()” command converts a number into a string. Several string variables
can be combined via simple addition. The “xs2gif(id,‘name’)” command saves the
content of the graphics window with identificatio number “id” to a GIF fil called
‘name’. Instead of using running numbers of 1, 2, 3, 4, . . ., which can lead to some
problems in the order of GIF f les, we rather choose a sequence 1001, 1002, 1003,
1004, . . .
3.5.6 Modifie Animation Script
The SciLab script including conversion of frames to GIF files called “WaveSimGif.sce” can be found in the folder “Miscellaneous/Waves” on the CD-ROM
accompanying this book.
23
SciLab can be used to write short simulation codes. Larger model codes, however, would take too long to run in SciLab and the preference in these cases should
be FORTRAN. Specifi SciLab plotting commands are explained in due course of
this book.
3.5.5 The First GIF Animation
To produce a GIF animation watchable in most Web browsers, each picture frame
produced in the SciLab script needs to be converted to an individual numbered GIF
image. To this end, the script needs two additions. The following line needs to be
added directly after the start of the animation loop:
scf(0); //set ID for graphic window
This allocates an identificatio number (0 here) to the graphics window. Within
the animation loop, content of the graphics window can then be converted to a GIF
fil with:
if n < 10 then // n is the loop counter
xs2gif(0,‘MyFirst100’+string(n)+‘.gif’)
else
if n < 100 then
xs2gif(0,‘MyFirst10’+string(n)+‘.gif’)
else
xs2gif(0,‘MyFirst1’+string(n)+‘.gif’)
end
end
The “string()” command converts a number into a string. Several string variables
can be combined via simple addition. The “xs2gif(id,‘name’)” command saves the
content of the graphics window with identificatio number “id” to a GIF fil called
‘name’. Instead of using running numbers of 1, 2, 3, 4, . . ., which can lead to some
problems in the order of GIF f les, we rather choose a sequence 1001, 1002, 1003,
1004, . . .
3.5.6 Modifie Animation Script
The SciLab script including conversion of frames to GIF files called “WaveSimGif.sce” can be found in the folder “Miscellaneous/Waves” on the CD-ROM
accompanying this book.
