First, are A, B, and C
subsystems?
If not, Simulink requires that every output variable in a MATLAB Function block have a fixed dimension.
If the variable V
in Block C is not completely assigned or assigned values of different sizes in different conditions, Simulink cannot determine its dimension at compile time.
Hence the error
For instance:
function V = fcn(U)
if U > 0
V = [1; 2; 3];
else
V = 0;
end
In the code above, the output size of V
changes depending on the condition.
To solve:
Clearly declare the size of V
So it remains constant:
function V = fcn(U)
V = zeros(3,1); % fix size at 3x1
if U > 0
V = [1; 2; 3];
else
V = [0; 0; 0];
end
Another way is that you can enable visual- signal in MATLAB settings
Open the MATLAB Function Block → Edit Data → check Variable size, set upper bound