'save as' command

5 次查看(过去 30 天)
Valentino
Valentino 2015-2-24
编辑: Valentino 2015-8-6
Hello I'm searching for a command in my GUI(with guide) to save the data in a file which is named by user Input. I would like to have a pushbutton and it opens a window where the user just have to insert the name of the file.
See my Code:
function save_as_Callback(hObject, eventdata, handles)
result.data=getappdata(handles.data,'results_data');
result.data_new=getappdata(handles.data,'results_data_new');
save ('','result') %here user should Input Name of file but in my GUI

采纳的回答

Titus Edelhofer
Titus Edelhofer 2015-2-24
编辑:Titus Edelhofer 2015-2-24
Hi Valentino,
use uiputfile for this task, something like
[fName, pName] = uiputfile('*.mat');
if fName==0
% user pressed cancel
return
end
save(fullfile(pName, fName), 'result');
Titus
EDIT: corrected the typo, thanks
  1 个评论
Valentino
Valentino 2015-2-24
编辑:Valentino 2015-8-6
Thank you! it works fine, you just got a typing error in the first line.
[fName, pName] = uiputfile('*.mat');
if fName==0
% user pressed cancel
return
end
save(fullfile(pName, fName), 'result');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by