MATLAB: Managing directory paths

directory pathspwd

I want to shorten a directory path. What I'm looking to do:
Use pwd to return the current folder (which in this example is 'c:\Asset_Allocation\Matlab_codes').
Shorten this path by one folder, i.e. I want to return 'c:\Asset_Allocation'.
What's the simplest way to do so?

Best Answer

S = 'c:\Asset_Allocation\Matlab_codes';
P = fileparts(S)