MATLAB: Creating Variable Output Filename

filenamevariable

Hi, I have a script that generates a pdf full of plots.
I would like the output filename *.pdf file to be automatically named according to a variable which contains a date and title
How can I insert a variable filename?
This is the code which saves everything into a pdf:
ps2pdf('psfile', 'myfile.ps', 'pdffile', 'filename.pdf', 'gspapersize', 'a4')
Thanks,

Best Answer

psfilename = sprintf('myfile%s.ps', datestr(TheDate, 'yyyymmdd') );
ps2pdf('psfile', psfilename, 'pdffile', 'filename.pdf', 'gspapersize', 'a4')