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

1 visualizzazione (ultimi 30 giorni)
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.

Risposte (1)

Fangjun Jiang
Fangjun Jiang il 14 Nov 2022
Don't do "F9". Add a break point in the Editor, press the "Step" and other buttons to debug.
  2 Commenti
Dogan Yildiz
Dogan Yildiz il 14 Nov 2022
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.
Fangjun Jiang
Fangjun Jiang il 14 Nov 2022
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.

Accedi per commentare.

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by