Repetitive Equation Structures with for-equations

1 Gneral Description

Repetitive equation structures can be expressed rather compactly with the special syntactic form of equation called a for-equation. Such a structured equation can be expanded to a sometimes large number of simple equations. The iteration-variable ranges over the set of values in the iteration-set-expression which must be a vector expression with parameter or constant variability. This expression is evaluated once in each for-equation, and is evaluated in the scope immediately enclosing the for-equation. Such a scope can typically be the scope of an enclosing class definition or the scope of an enclosing for-equation.


2 FiveEquations


3 Simulation of FiveEquations

Here the simulation of FiveEquations is shown.





4 FiveEquationsUnrolled

FiveEquations has the same behavior as the class FiveEquationsUnrolled where the for-equation has been unrolled into five simple equations.



5 Simulation of FiveEquationsUnrolled

Here the simulation of FiveEquationsUnrolled is shown.





6 HideVariable

Since the scope of the iteration variable is the enclosing for-equation, it may hide other variables with the same name, e.g. the constant k declared in the class HideVariable. Note that the k used in the iteration expression 1:k+1 is the constant k declared in the class, whereas the k used in the equations inside the for-clause is the iteration variable k. You should avoid this style of modeling, even if it is legal, since it is confusing and hard to read such code.



7 Simulation of HideVariable

Here we simulate HideVariable.