MATLAB Answers

0

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

Asked by deenessen armoogum on 1 Jun 2019
Latest activity Commented on by deenessen armoogum on 5 Jun 2019
How to do it?

  0 Comments

Sign in to comment.

Products


Release

R2007a

2 Answers

Answer by Geoff Hayes
on 2 Jun 2019
Edited by Geoff Hayes
on 2 Jun 2019
 Accepted Answer

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 Comments

Do you have the callback for the pushbutton? Please share some of your code.
I want to put all the coding in the pushbutton

Sign in to comment.


Answer by deenessen armoogum on 3 Jun 2019

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

  0 Comments

Sign in to comment.