Question

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.

Was it helpful?

Solution

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].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top