How can I add all subfolders to my MATLAB path?
For example, my matlab folder ‘current_use’ is under the directory user/example/matlab/current_use and under ‘current_use’ folder there are 6 subfolders and each contains data files I need to test, i.e., my matlab script under folder ‘current_use’ will call all data under the subfolders which are inside folder ‘current_use’
What I am doing now is each time tell matlab the path of each my subfolder, i.e., inside my script I have a comment to tell matlab to look the path ‘user/example/matlab/current_use’.
It works. However, now I need to upload my code to the school server to run it. But after I upload everything onto school server, the path ‘user/example/matlab/current_use’ will no longer by correct. i.e., the part ‘user/example/matlab/’ is changed.
So I am wondering, is there a way that I can let matlab to add all subfolders under current folder without tell it where is the current folder? or, is there a comment that matlab can use to obtain the path for the current folder?
NOTE:-
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
This should work regardless if your current folder is the one that contains your m-file, or not.
% Determine where your m-file's folder is.
folder = fileparts(which(mfilename));
% Add that folder plus all subfolders to the path.
addpath(genpath(folder));
SEE COMPLETE ANSWER CLICK THE LINK