MATLAB: Using strings in regular code.

stringstrings

Simple question. I've looked around the documentation and can't seem to find this.
How do I use a string and pass it into code?? Example:
%I create a string
Str = Superman
then how do I pass this string in the saveas command? So instead of writing this line of code:
saveas(gcf,'Superman.fig');
I would write something to the effect of:
saveas(gcf,''Str'.fig') or something?!?!??!?!?
Thanks!

Best Answer

For me, to construct the name of the file (it's what I use)
FileName = 'Superman' ;
FileDir = 'I:\..\MyDir'
FilePath = fullfile( FileDir, sprintf( '%s.fig', FileName ));
saveas(gcf,FilePath)
You can write this in one line if you want