How do you create a push button that saves data from a GUI?

 採用された回答

Geoff Hayes
Geoff Hayes 2019 年 6 月 2 日
編集済み: Geoff Hayes 2019 年 6 月 2 日

0 投票

deenessen - you haven't given us much to work on, but presumably your GUI has a button that, when pushed, you want to save some data to an Excel file. Assuming that GUIDE is being used, then your pushbutton callback would look like
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% get and format your data
myData = randi(42, 10,3);
% write your data to file
writematrix('myFile.xlsx', myData);
Depending upon your version of MATLAB, you could use writematrix or xlswrite.

10 件のコメント

deenessen armoogum
deenessen armoogum 2019 年 6 月 2 日
編集済み: deenessen armoogum 2019 年 6 月 2 日
Infact i want to store data such as a bill balance into an excel file just by clicking on the pushbutton @geoff
Geoff Hayes
Geoff Hayes 2019 年 6 月 2 日
Well where does the bill balance data come from? What format should it be in?
deenessen armoogum
deenessen armoogum 2019 年 6 月 2 日
編集済み: deenessen armoogum 2019 年 6 月 2 日
@Geoff There will be a edit box in which i will insert the balance bill and then the pushbutton should store it in the excel file
Geoff Hayes
Geoff Hayes 2019 年 6 月 2 日
Is this just one value or will it change over time (and so you will need to store the new value in the spreadsheet)? Try writing the code to do this.
deenessen armoogum
deenessen armoogum 2019 年 6 月 3 日
@Geoff it will change over time Can you plz give me a hint how to write it or a sample on how it should look thks in advance sir
Geoff Hayes
Geoff Hayes 2019 年 6 月 3 日
deenessen - but what have you tried so far? Have you designed your GUI? Have you used GUIDE, App Designer, or programmatically created the GUI?
deenessen armoogum
deenessen armoogum 2019 年 6 月 3 日
Programmatically use gui I have already created the edit box and pushbutton so far
Geoff Hayes
Geoff Hayes 2019 年 6 月 3 日
Do you have the callback for the pushbutton? Please share some of your code.
deenessen armoogum
deenessen armoogum 2019 年 6 月 5 日
I want to put all the coding in the pushbutton
deenessen armoogum
deenessen armoogum 2019 年 6 月 5 日

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

その他の回答 (1 件)

deenessen armoogum
deenessen armoogum 2019 年 6 月 3 日

0 投票

Programmatically use gui I have already created the edit box and pushbutton so far

1 件のコメント

Ron
Ron 2024 年 5 月 3 日
can you let us know how you were able to do so?

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

製品

リリース

R2007a

Community Treasure Hunt

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

Start Hunting!

Translated by