user1574598
user1574598

Reputation: 3879

Problems with Embedded Functions within Simulink

I'm trying to simulate a very simple model using an embedded matlab function that takes the input and add's 10 to the value using a constant block that inputs into the matlab function, which then outputs to a display block.

As soon as I press simulate I get an abundance of errors. First I get a huge paragraph in orange text stating a warning out the solver 'variableStepDiscrete' instead of solver 'ode45'

Here is the remaining lines that are echo'd from the command prompt:

Code Directory :
 "/Users/dazgti/Documents/MATLAB/slprj/_sfprj/embeddedFunction/_self/sfun/src"

Machine (#32): "embeddedFunction"  Target : "sfun"


Chart "MATLAB Function" (#49):

.
     "c2_embeddedFunction.h"
 "c2_embeddedFunction.c"

 "embeddedFunction_sfun.h"

 "embeddedFunction_sfun.c"

 "embeddedFunction_sfun_debug_macros.h"


Interface and Support files:

 "embeddedFunction_sfun_registry.c"

Code generation failed Attempt to execute SCRIPT union as a function:
/Users/dazgti/Documents/MATLAB/union.m

I have a script file within my matlab directory called union.m, but I have no idea why its mentioning it.

sim

function y  = fcn(u)
%#codegen

x = u + 10;

y = x;

Upvotes: 0

Views: 1672

Answers (1)

Navan
Navan

Reputation: 4477

MATLAB Function block works by generating "C" code for the MATLAB code you entered in the block. In the process of generating code there could have been a call to union function in MATLAB from MATLAB Function block infrastructure. Since you have overridden the union function instead of the built-in function MATLAB might have attempted to call your script which caused the error. It is better to avoid naming your functions same as MATLAB built-in functions.

Upvotes: 1

Related Questions