save function; path and file name as variables

21 ビュー (過去 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 Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by