MATLAB: Save function; path and file name as variables

save

Matlabe newbie – so please bear with me. I want to use save, but make the file path and file name as variables:
MyDir='C:\TargetDir;
MyScript='RegExample.m';
*save(MyDir\MyScript)*
I've tried different variations of save, but am not able to get it to work. Any suggestions? Thanks C

Best Answer

This seems to work:
MyDir='C:\Dir\';
MyScript='RegExample.m';
MyFile=strcat(MyDir,MyScript);
save(MyFile)
If there's a better way, I'd be happy to know....