Interpreted MATLAB function on simulink running a MEX file repeatedly
1 view (last 30 days)
Show older comments
I have a Simulink model running an intepreted matlab function, which in turn runs a MEX funtion. I have been having memory-related problems, stemming from the fact that this mex file gets run far more than I think it should given the nature of the model.
It seems the culprit is the intepreted matlab function. The intepreted matlab function is only supposed to run the MEX file once per step, but for some reason, it gets run about 70 times. The simplified model looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/384598/image.png)
Where the user defined fcn is as follows:
function y = fcn(u)
disp("This is a test right before main mex call.")
y = u;
and the Interpeted function is:
function c = running_mex_File(input_init)
c = helloworld(input_init);
clear mex;
end
And the MEx Function Hello World ends with the statement
MexPrintf("Ran Well")
A sample output from the consol is:
This is a test right before main mex call
Ran Well
Ran Well
Ran Well
(about 60 more 'Ran Well's)
This is a test right before main mex call
Ran well
Ran Well
Ran Well
etc..
Why would this not come out as:
This is a test right before main mex call
Ran Well
This is a test right before main mex call
Ran well
This is a test right before Main mex call
Ran Well
etc.
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!