MATLAB: Having Matlab automatically choose the directory I am in

fopenMATLABuigetdir

All,
I have a code that references the user directory that I am in:
userDir = uigetdir('C:\','Browse to station directory');
filePath = [userDir,'\station_data_',datestr(now,30),'.txt'];
fid = fopen(filePath,'w');
Then the rest of my code (which is not listed here) executes based on the directory that I choose. I will say that I always want to choose the directory that I am in (The one that is listed on the left side of Matlab under "current folder").
Is there any way to not have to prompt the user to input the directory I am in, and just have Matlab automatically use the directory that I am in when I run the code?
I want to eliminate the need to prompt the user to use the current folder that I am in by having him/her typing it in with the prompt:
userDir = uigetdir('C:\','Browse to station directory');
Any help is greatly appreciated. Respectfully, Charles

Best Answer

pwd returns the current directory. On Unix-based machines, the tilde (~) is shorthand for the current directory.