Exercise 2 - Initialization of Variables

1 Question

How can a variable be initialized?


If nothing is specified, the default start value of all numerical variables is zero, apart from function results and function local variables where it is unspecified. In functions you can use an assignment in the declaration to set the default value.

Start values can be specified by setting the start attribute of instance variables using a modifier equation, see the next section..

You can also set the initial value using a when-equation as below. An event is generated at the start of the simulation by initial(), which activates the initializing equation.

An initial equation section is a general way of initializing variables. It can also be used for setting initial values of derivatives.

2 Initializing Variables

Declare the variables length1, length2 and length3 of type Real with different initial values. One of the variables should have the value 0. Name the class Variables.