save function; path and file name as variables

조회 수: 44 (최근 30일)
Chet Sharma
Chet Sharma 2017년 11월 18일
댓글: per isakson 2017년 11월 18일
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