How do I call an anonymous function inside the MATLAB function block in Simulink 8.1 (R2013a)?
Show older comments
I have a model which has the MATLAB function block. I want to be able to call the FMINBND anonymous function within this block.I understand that this is a function that is not within the list of supported functions for the MATLAB function block and so I use coder.extrinsic to declare FMINBND as follows:
function y = fcn()
%#codegen
coder.extrinsic('fminbnd')
y = fminbnd(@(x) x.^2+100-650, 0, 100);
end
However, I get the following error when I run the model:
This kind of expression is not supported.
How do I get around this?
Accepted Answer
More Answers (1)
Walter Roberson
on 21 Apr 2018
Edited: Walter Roberson
on 21 Apr 2018
If sum(q) == 0 because all of the entries are 0, then you only store into Q(1) and none of the other locations in Q.
Remember that the first assignment to a variable determines the size of the variable, so the first thing you should do is
Q = zeros(1,n);
Categories
Find more on Simulink Functions 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!