2
votes

I have the following code in an embedded matlab function in simulink:

 function rad = fcn(lenkwinkel)
if lenkwinkel < 0
    rad=[0 1 0 0];
elseif lenkwinkel > 0
    rad=[1 0 0 0];
else
    rad=[0 0 0 0];
end

In the simulation I have the "lenkwinkel" variable connected to the MATLAB Function Block,which is connected to a Mux block with 4 ports.

I am trying to use the function to send a vector with 4 binary elements to the Mux block, which then should split it into 4 signals. Unfortunately, this is not working. When I try to run this, I get:

Inferred size ('[1 4]') for data 'rad' (#44) does not match back propagated size ('[4]') from Simulink.

Can anyone help me with this? Thanks a lot.

1
Do you mean DeMux? If the demux is connect to a Scope then the model as described works for me (in R2013b). What do you have connected to the output of the demux?Phil Goddard
Hello there. Yes, I am sorry. I do mean DeMux. On the left side, the DeMux connects to the function and on the right side it splits into 4 port, where each connects to a product block. Thanks.thephphero

1 Answers

2
votes

I am assuming you mean DeMux as well, please correct us if that is incorrect. From the looks of it, the MATLAB Function block has determined that the size of rad is 1-by-4 since that is the size of the value assigned to it. However, something else seems to think that the output should be of size [4] or 4-by-1. Have you manually specified the output of the MATLAB Function block to have size [4] or the size of the demux to expect an input of size [4]?

You could either change the definition of rad to be 4-by-1 or the size specified to Simulink to be [1, 4].