Guy on Simulink

Simulink & Model-Based Design

Why you should use the Function-Call Split block

Today I had a good discussion with a user regarding theFunction-Call Splitblock introduced in R2010a.

On one side, the user claimed that there was no need for aFunction-Call Splitblock. For example, in the following model the Demux block can be used to obtain results similar to theFunction-Call Splitblock.

Comparison between Demux and Split

I personally think that there are many reasons why you should always use the Function-Call Split block and avoid using the Demux block to manipulate Function-call signals.

Really Splitting One Function-Call

In the previous model, the Demux block can be used to split the function-call because it originates from theFunction-Call Generatorblock. To be accurate, in that case we need to notice that the Demux block does not split one function call... it is the Function-Call generator block that generates 2 function calls. As shown in the image below, a dimension 2 is specified in the Demux block and back-propagated to the Function-Call Generator... resulting in a not very obvious case ofscalar expansion.

Back Propagation of Fcn-Call dimension

If you try the same with a function-call generated by aMATLAB Functionblock or aStateflowchart, you will get an error. To split a function call from one of those, you need to use theFunction-Call Splitblock.

Using a Split to split function-call generated by the MATLAB Function block

Data Dependency Checking

If you implement the following model, it will simulate and generate code without error or warning. When this happens in a large model, it might not be obvious to the user that there is an implicit delay because A runs before B, but requires data from B.

Feedback with Demux

If you use theFunction-Call Split块,你将get a clear error message explaining your options. If the delay was not expected, you can rearrange the order of your function-calls. If the delay is expected, then you can insert aFunction-Call Feedback Latchblock to explicitly specify it.

Feedback with Split

Better Display of Sorted Order

Let's say you write an S-function that generates a vector of two function-call signals and you separate them using a Demux block. Just by looking at the model, it is impossible to know in which order the function-call subsystems will execute. If you display thesorted orderall the destinations are marked identically in the formatS:F.

Sorted Order with Demux

With the Function-Call Split block, everything becomes clearer. Only one function-call signal is generated by the source, and the order into which the function-call subsystems execute is displayed with a formatS:B#, where#is the order of the branch.

Sorted Order with Split

Now it's your turn

What do you think of the Function-Call Split block? Let us know by leaving acomment here.

|

Comments

To leave a comment, please clickhereto sign in to your MathWorks Account or create a new one.