Hi Elise,
The ' sprintf ' function is used for formatting certain input data to string. I am not entirely sure about your use of the 'sprintf' function to define the name for the pdf file. Since your figure is getting saved as a .fig file, I would recommend you to use the following syntax for the ' saveas ' function.
>> saveas(gcf,'MyPDFFileName','pdf');
The above code will save the current figure in a file MyPDFFileName.pdf. Depending on the type & dimensions of the 'name' variable in the code snippet you have provided, you can set the name of the PDF file accordingly.
I hope this helps!
-Rohit