save function; path and file name as variables

44 次查看(过去 30 天)
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

采纳的回答

Chet Sharma
Chet Sharma 2017-11-18
编辑:per isakson 2017-11-18
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....

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by