MATLAB: Add directory path to fopen

createdirectoryfilefopen

I have this code:
name = strrep(name,' ','_');
date = strrep(date,' ','_');
FileName=[name '_' date '.txt'];
file=fopen(FileName,'wt');
it creates a text file with the name and date I get from some edittext box in GUI in the current folder.
Can I add a directory path to that so it creates the text file in another folder like: ../DB/filename.txt ?

Best Answer

file=fopen(fullfile(pwd,FileName),'wt')