Navigation:  Language Reference > Functions > Port >


Previous pageReturn to chapter overviewNext page


y = collect(p.e);

y = collect(p.f);

y = collect(m);


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


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]


To assign an array of unknown length, the collect function is used. It creates an array with port variables or signals. 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!


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


Y = collect(p.e);


During processing, this equation will be rewritten as:


Y = [p.e1;p.e2;...;p.n];


Suppose we have a submodel with n input signals connected. We could then write the equation:


y = sum(collect(input));


During processing, this equation will be rewritten as:


y = sum([output1;output2;...;outputn]);


which is of course equal to:


y = output1 + output2 + .. + outputn;


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.