Why Command Window cannot access custom Functions defined in end of Matlab Script?

58 views (last 30 days)
Hi,
I have defined custom Functions that can be accessed by code within the Script. However, calling the function from the Command Window returns "Unrecognized function or variable". Any recommendation to rectify this?
Thanks,
Sujith

Accepted Answer

Cris LaPierre
Cris LaPierre on 31 May 2020
Functions defined at the end of a script or function file are called local functions. By design, these cannot be accessed outside the file in which they were defined. If you want to create a function you can call from any script or function. you must place just that function in a file all by itself. Convention dictates that the function name and filename should be the same.
You can learn more about functions here.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!