I need to implement a Matlab function block which creates matrices according to a given size specified by an input signal. The size value is constant(!) throughout a simulation, and I don’t want to use superfluous variable-size stuff, as I don’t want to overcomplicate my simulation and sample the block totally needlessly.
Easy example for the Matlab function: y = zeros(x) with x being the input signal of the Matlab function block and y being the output signal. That input gets connected to a Constant block set to a fixed value of say 5. Then this block should do nothing more than create a 5x5 matrix full of zeros. I am not able to do this without messing the whole simulation up with variable-sized signals and needless block sampling.
I would appreaciate it a lot, if someone can help, me. That already costed me days.
No matter what I do, I always get the error message:
Data 'y' is inferred as a variable size matrix, while its properties in the Model Explorer specify its size as inherited or fixed. Please check the 'Variable Size' check box and specify the upper bounds in the size field.
But that signals is not variable at all, it’s absolutely fixed! So I do not understand at all how Simulink cannot be able to infer the signal size from that constant value.
Matlab function block content