Save button in GUI Matlab

6 ビュー (過去 30 日間)
Chris Dan
Chris Dan 2020 年 7 月 22 日
編集済み: Cris LaPierre 2020 年 7 月 22 日
Hello,
I am developing a GUI and to save the files, I am currently using this commad
save('SystemMatrices.mat','Mass_Global', 'Damp_Global', 'Stiffness_Global','GlobalMesh')
% this is my save button
function SaveGlobal_Callback(source,eventdata)
[file,path,indx] = uiputfile();
end
I created a save button, but what should i write in it so that the user can choose the location and the name for the file to save. Basically it should be similar, but the user can choose the saving directory, and save 'Mass_Global', 'Damp_Global', 'Stiffness_Global','GlobalMesh in one file
I read this documentation:
but I dont know how it can be applied here
Does anybody know ?

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 7 月 22 日
編集済み: Cris LaPierre 2020 年 7 月 22 日
Here, your code could be something like this. Keep in mind variable scope in functions. If the specified variables do not exist in your callback function, you'll need to pass them in or create them inside the function. Since I don't know how they are created, i've left that open ended here.
% this is my save button
function SaveGlobal_Callback(source,eventdata)
Mass_Global = ...;
Damp_Global = ...;
Stiffness_Global = ...;
GlobalMesh = ...;
[file,path] = uiputfile('*.mat');
save(fullfile(path,file),'Mass_Global', 'Damp_Global', 'Stiffness_Global','GlobalMesh')
end
  1 件のコメント
Chris Dan
Chris Dan 2020 年 7 月 22 日
Thanks :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by