adam.john_1289 asked . 28/011/2019

How do I use the addpath( ) function in MATLAB?

How do I use the addpath( ) function in MATLAB?

Matlab

Expert Answer

Kshitij Singh ( Staff ) answered . 30/11/2019


addpath() basically used for adding folders to search path.
You can add like this
1. at top of file

mkdir('matlab/myfiles')
addpath('matlab/myfiles')
savepath matlab/myfiles/pathdef.m2
2. at end of file
mkdir('matlab/myfiles')
addpath('matlab/myfiles','-end')
3. Adding folders and sub folders
mkdir('matlab/myfiles')
addpath(genpath('matlab/myfiles'))