MATLAB: Saving the own function to be used as MATLAB built-in functions

built-in functions

I would like to write a function that can be called from anywhere regardless of my current working path, just like I use integral(…) or sin(…). How should I change the setup to be able to do this?

Best Answer

Create a startup.m file in your MATLAB user folder(usually Documents/MATLAB) then use addpath in that file.
MATLAB will execute that file everytime it starts up, meaning the paths you specify in that file will be "permenantly" available in any folder for all intents and purposes. (At least for all cases someone asking this question will likely encounter.)