first

Navigation:  Language Reference > Functions > Port >

first

Previous pageReturn to chapter overviewNext page

Syntax

y = first(p.e);

y = first(p.f);

y = first(m);

 

(with p.e and p.f powerportvariables and m a signal)

Description

Some models in 20-sim can have an unknown amount of signals or bonds connected. They are treated as an array with unknown length. For example the PlusMinus model can have n signals that must be added and m signals that must be subtracted. 20-sim treats them as an array plus and an array minus with:

 

plus = [plus1;plus2;..;plusn] and minus = [minus1;minus2;..;minusm]

 

The function first returns the value of the first element of an array of unknown length. This function is created for use in library models that have an unknown amount of bonds or signals connected. Try to avoid the use of this function!

Examples

Suppose we have m bonds connected to a submodel, collected in a port p. We could then use the equation:

 

y = first(p.e);

 

During processing, this equation will be rewritten as:

 

y = p.e1;

 

Limitations

This function is designed for a special class of models and should be used by experienced users only! The function is only valid when used in a submodel.