Save a .mat file that starts with a hyphen (negative sign)

8 ビュー (過去 30 日間)
Matt C
Matt C 2017 年 3 月 15 日
回答済み: Walter Roberson 2017 年 4 月 1 日
Is it possible to save a file that starts with a hyphen? At one point this was possible, because I have found a ton of .mat files that start with a "negative" sign - has this ability changed since MATLAB 2009b (or Windows XP), or have I just forgotten how to do this? I'm currently using 2015b/Windows 7. Any help would be appreciated.
Example:
x = 2;
y = -x;
save('myVariable.mat','x');
save ('-myVariable.mat','y');
The second save will error-out, because MATLAB is seeking a command option.
Thanks in advance!
- Matt

採用された回答

Matt C
Matt C 2017 年 4 月 1 日
I have the answer! If you feed the save and load commands the full path of the file in question, you can then save and load files that start with a dash!

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 4 月 1 日
You can use ./ immediately before the file name
save ('./-myVariable.mat','y');
This will work for Windows as well as Mac and Linux

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by