MATLAB: Save folder one above current directory

directories

Let's say I am working in the directory:
/home/username/Matlab/
I want to save (in a script) the directory one above the one I am working in (to use it later in the script), so:
newdir='home/username';
But I am working in different computers, so the 'username' changes, thus I want to do it automatically, such as save "newdir" as "one above the current directory".
Thank you

Best Answer

Zynk - try using pwd with strfind to determine the index of the last occurrence of the slash /. Then just remove it and everything that follows. Something like
mydir = pwd;
idcs = strfind(mydir,'/');
newdir = mydir(1:idcs(end)-1);
Try the above (or a variation of it) and see what happens!