Scilab environment. ▷ two windows: console and editor. ▷ console: type
commands directly (history and T-key). ▷ editor: type (longer) commands, save
and ...
A quick introduction to Scilab Tutorial on Risk Management, WS 2013/14
Outline
Scilab environment
I
two windows: console and editor
I
console: type commands directly (history and ↑-key)
I
editor: type (longer) commands, save and execute them
I
help-files: description and examples of commands
Basic elements of the language
I
real variables and basic mathematical operations
I
matrices I I I I
creation of matrices ([], ones, zeros) access to matrices ((3,4), :, $) basic operations (+, -, *, ’) element-wise operations (.)
Basic elements of the language (continued)
I
branching and looping I if, elseif, else I for
I
functions I I
definition of a function multiple input and output arguments
Writing good code
I
Choose meaningful names for variables and functions.
I
Use indentation for a better overview.
I
Avoid hard-coded constants, but use variables instead. (length)
I
Is your for loop necessary? Employ vectorization.
I
Whenever you write code of the same pattern twice, define a function.
Avoiding and finding errors Avoiding errors I
Be sure to know exactly what your command does (if not, try it on the command line).
I
Proceed step by step. Test after every step.
I
Always close a bracket at the same time you open it.
I
Use variables as arguments to test your function.
Finding errors (debugging) I
If the real input is long, use a short example for testing.
I
pause command (resume, abort)
I
variable browser
I
plausibility tests: special cases, extreme values, monotonicity
Stixbox
Installation of the the Scilab module Stixbox I
search for available modules: atomsSearch("stixbox")
I
install stixbox: atomsInstall("stixbox")
I
restart Scilab or use atomsLoad("stixbox")
Why do we need Stixbox? I
statistics toolbox: distribution functions, statistical tests, plotting facilities, etc.
I
we can use a lot of commands without implementation