This is an incredibly useful function if one has to move around in the Matlab main directory a lot. For what I am doing I need to retrieve audio/image files from one folder, analyze them and save the output to another folder. Since I don’t want thousands of generated pictures ending up in the wrong directory, I use full paths. To start I always need the home directory:


function path = MRgoToHome()
%    path = MRgoToHome() – report the current (matlab) home directory and switch to it
%    path       – path to home directory

path = userpath;
path = path(1:end-1);

cd (path);