In MATLAB, you can call a function defined in a different script by using the function name preceded by the script name or file path where the function is defined.
Assuming there's a function called myFunction
in a script called myScript
located in the same folder as the current script, you can call that function by simply typing:
main.m37 chars2 lines
Alternatively, if the script file is located in a different folder than the current script, you can either add the folder to your MATLAB search path, or include the file path when calling the function. For example:
main.m74 chars3 lines
main.m57 chars2 lines
Note that if the function you want to call is defined inside a namespace (i.e. preceded by the function
keyword), you need to specify the namespace as well. For example:
main.m49 chars2 lines
gistlibby LogSnag