cell operations for varargin and varargout

2 views (last 30 days)
Hi fellows matlab. I wrote the next code into MATLAB embedded function block from SIMULINK, but I get the next warning advice in the embedded MATLAB editor wich I don't know how to resolve..
if true
error(nargchk(1,2,nargin));
[n,dims] = size(xy);
numels = n*n*dims;
opt = 2; if numels > 5e4, opt = 3; elseif n < 20, opt = 1; end
for var = varargin
if length(*var{1})* == 1
opt = max(1, min(4, round(abs*(var{1}*))));
else
error('Invalid input argument.');
end
end
the message said the embedded MATLAB only supports cell operations for varargin and varargout pointing var{1}
how should I resolve it? regards!!

Answers (1)

Ryan G
Ryan G on 6 Nov 2012
Unfortunately cell arrays are not really supported for code generation, which is essentially what embedded MATLAB does to run.
If you do not require code generation for this part of the model, you can define the function externally, define the function as extrinsic:
coder.extrinsic('myMatlabFunction')
at the beginning of your embedded matlab code, then call it as you normally would. This tells the block to call the function using the MATLAB interpreter instead of trying to generate code.

Community Treasure Hunt

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

Start Hunting!