save function; path and file name as variables

22 vues (au cours des 30 derniers jours)
Chet Sharma
Chet Sharma le 18 Nov 2017
Commenté : per isakson le 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

Réponse acceptée

Chet Sharma
Chet Sharma le 18 Nov 2017
Modifié(e) : per isakson le 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....

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by