save function; path and file name as variables

20 Ansichten (letzte 30 Tage)
Chet Sharma
Chet Sharma am 18 Nov. 2017
Kommentiert: per isakson am 18 Nov. 2017
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

Akzeptierte Antwort

Chet Sharma
Chet Sharma am 18 Nov. 2017
Bearbeitet: per isakson am 18 Nov. 2017
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....

Weitere Antworten (0)

Kategorien

Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by