Simulink Local function debug gives "Undefined function 'myFunc' for input arguments of type 'double'"

Hi Everyone,
During the debug process of my Simulink model I encountered an "Undefined function 'myFunc' for input arguments of type 'double'" type error. I created a simple demo model to show you the error. Basically, in Simulink I created a Matlab Function 'sumCode', and a local function within it which is 'crossCode'. When I debugged my code, I inserted a debug point and tried to evaluate that line with F9 and Matlab gives me
"Undefined function 'crossCode' for input arguments of type 'double'." type error. I share the screenshots below.
I tried a similar scenario with the Matlab script, I could run and evaluate the selection with F9 in debug successfully. Do you have any suggestions to handle this problem in Simulink?
Thank you very much for your time.

Antworten (1)

Don't do "F9". Add a break point in the Editor, press the "Step" and other buttons to debug.

2 Kommentare

Why not ? Older versions of Matlab allow to test inner functions with F9. Also why Matlab gives such an error ? The real problem is giving undefined function error even there is a local function in code. Thank you for the reply.
What "F9" does is to copy the string and evaluate it in MATLAB Command Window. In your case, execute "c = a+b+crossCode(a,b)". The "debug>>" prompt indicates it is in the function workspace, but the file visibility is still with MATLAB. In other word, in MATLAB Command Window, it does not see function "crossCode()" because it is a "local" function, just the same as it won't be able to call any local functions inside any .m file.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink Environment Customization finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2021b

Gefragt:

am 13 Nov. 2022

Kommentiert:

am 14 Nov. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by