- you can use function handle to do the same thing, and here is the doc link - https://www.mathworks.com/help/matlab/matlab_prog/creating-a-function-handle.html. For example, create a function handle like this in your script.
- Create a function to put your formula, and here is the doc link - https://www.mathworks.com/help/matlab/ref/function.html. just call the function in your script. Please be aware you need to put function in the same directory with your scrip or add the function to your path when you run your script. Otherewise it might not be able to find the function. Function example is like the following: