Problem with variable size output/input signals in Embedded Function Blocks in Simulink

1 view (last 30 days)
Hello Everyone ,
Problem Situation : I have a M Function which i need to use in Simulink . lets say that I need to use following function.
function [a,b] = foo(p,q,r)
%#codegen
% Some operation
end
So , Regarding this Function, Some of the inputs are constants, some of them are varying size input/outputs for different time steps. When I was trying to run the model ,it did throw me a warning saying about the varying sizes of inputs/outputs. Then I went to model explorer, and did navigate to the Corresponding function , and checked the "variable size" box for variable inputs/outputs and left the size as -1... For those as constants , I gave the size as [1 1] and leaving the "variable Size" unchecked.
but still I get an error Like
Output 'OutputLaneData' has variable size but the upper bound is not specified; explicit upper bound must be provided.
Do i need to explictly mention the maximum limits of all outputs in the function like this
function [a,b] = foo(p,q,r)
%#codegen
coder.varsize('a',[1 10000]); % The Maximum size of a can be [1 x 10000]
coder.varsize('b',[1 99999]); % The Maximum size of a can be [1 x 99999]
% Some operation
end
Even though I did something like to this to my functions, it still complains me . I even did add maximum and minimum values in the model explorer... Do i still need to do something more ?? Am i missing anything ...
please comment to know about it... Any questions are welcome.
  3 Comments
Ash1992
Ash1992 on 27 Feb 2017
Hello Vandana .... The operations include some searching,filtering and Yes,I am performing some concatenation of those outputs with some constants if a conditions satisfies.
Sudarshan Kolar
Sudarshan Kolar on 27 Feb 2017
Edited: Sudarshan Kolar on 27 Feb 2017
You might find these docs helpful to resolve the issue:
1. https://www.mathworks.com/help/coder/ug/code-generation-for-variable-size-data.html (see generating code for MATLAB Functions with Variable-Size Data and the section after it)
2. https://www.mathworks.com/help/coder/ug/troubleshooting-issues-with-variable-size-data.html#br9sjhb
3. https://www.mathworks.com/help/coder/ug/variable-size-data-when-dynamic-memory-allocation-is-disabled.html#br9t1u3
The doc is suggesting to use coder.typeof:
https://www.mathworks.com/help/coder/ref/coder.typeof.html?s_tid=srchtitle

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!