62
2 Description of the Wolfram SystemModeler
Fig. 2.39 Setting model parameters
own components, which use standard formulas for calculating physical, geometric,
or other characteristics.
Addition: Functions
The function class describes a function written in an algorithmic language. Function
setting syntax:
function Square
// Declaring input and output variables
protected
// Declaring intermediate variables (if required)
algorithm
// Body function
end Square;
Input variables are declared with the input attribute, and output variables are
declared with the output attribute. For example, setting a function to calculate the
volume of a cylinder:
function CylinderVolume
input Real radius;
input Real length;
output Real volume;
algorithm
volume = 3.14159*radius^2*length;
end CylinderVolume;
You can call a function in several ways. You can explicitly specify the names
of input variables when calling a function, or you can simply call a function with
Précédent

- 75/274

Suivant