Non-tunable parameter size limit in matlab function in simulink
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey all,
I've encountered this weird behaviour with parameters in matlab function in simulink. Suppose you have this simple model:
The function does not have any inputs only a parameter (set to non tunable). The code inside looks as follows:
function y = fcn(paramIn)
y = fcnTest(paramIn);
end
function out = fcnTest(paramIn)
out = ones(paramIn.size, 1); % the size is set to 6
end
There is a subfunction that takes the parameter, and outputs a variable of a size that is defined in the parmeter (paramIn.size which is set to 6). In addition to that, in the ports and data manager, the size of the output of the function is explicitly defined:
Evertyhing works well with this. However, if I add another field to the parameter in the workspace, which is large, but has nothing to do with the aforementioned function, e.g.
paramIn.const = ones(530e3, 1, 'uint8');
Then I get an error:
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.
Which seems like the simulink stopped treating the paramIn structure as compile time constant. It is enough to reduce the size of the previously added const to:
paramIn.const = ones(520e3, 1, 'uint8');
And then it runs perfectly. So it really seems as if there is an upper boundary for parameter sizes (around 520kB) for them to be treated as not tunable (constant).
However, if the definition of the output size happens not in the subfunction, but in the main function, then there are no problems...
Am I missing here something? Or has anyone experienced this sort of behaviour?
Thank you for answers.
Bronius
0 comentarios
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!