how to name matfile from variable name
8 次查看(过去 30 天)
显示 更早的评论
I am trying to allow end users to name the .mat file that will save current settings as a preset.
What have tried so far is:
presetName = inputdlg({'Enter a name for the Preset'},'Preset');
%presetNameMat = strcat( presetName,'.mat');
save('presetName');
SaveUserSettings(handles);
Which saves everything in a file called presetName.mat - and not a .mat file named from the variable presetName. If I try and pass the value instead I get : Error using save Argument must contain a string.
0 个评论
采纳的回答
Star Strider
2016-6-9
This should work:
presetNameCell = inputdlg({'Enter a name for the Preset'},'Preset');
presetName = presetNameCell{:};
save(presetName);
You can of course combine them as:
save(presetNameCell{:});
I broke them out into separate lines so you can see how the code works.
更多回答(1 个)
Shameer Parmar
2016-6-10
Hi Kev111,
In your code, simply replace the line
save('presetName');
with
save(char(presetName));
and try..
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Big Data Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!