MATLAB Answers

0

Do Matlab Function blocks in Simulink run at different speeds?

Asked by Nathan Metzger on 24 Jan 2019
Latest activity Answered by Mark McBroom on 28 Jan 2019
Hello,
I have a question about a Simulink block diagram that utilizes a single input for multiple user-written Matlab Functions, and then feeds the outputs of each of those to a separate Matlab Function block. A simplified example of what I'm doing is shown below:
image (1).png
In the above diagram, will the 4th Matlab Function block wait for the first three? In my scenario, 1&2 run at about the same speed, but 3 is a much longer function that takes longer to run than the first two.
Currently, if I terminate the output of 3 and do not send it through the 4th, and scope the output, it does not give any errors and gives the expected output, but if I actually hook it up into the 4th Matlab function it says that Simulink cannot determine the output size of the block.
Is this an issue that anyone has encountered before and knows how to solve?
Thanks for any help!

  0 Comments

Sign in to comment.

Products


Release

R2018a

1 Answer

Answer by Mark McBroom on 28 Jan 2019

The 4th ML Fcn block will not run until all of it's input signals are calculated. You can view the order that Simulink will execute each block by showing the sorted order. Select following from Simulink menu: Display -> Blocks -> Sorted Execution Order. However, this is not the cause of your error.
The problem is that the size of the output signal from ML Fcn block 3 can't be determined. To see what Simulink thinks the size of each signal is, select the following from Simulink menu: Display -> SIgnals & Ports -> Signal Dimension.
I would recommend going into ML Fcn block 3 and making sure the size of the output signal is explicitly specified. For example, this code, when placed at the top of the ML Fcn, initializes y to be a vector of size 3.
y = zeros(1,3);

  0 Comments

Sign in to comment.