Azzera filtri
Azzera filtri

how i use "edit text" as input and "push button" as output in gui

5 visualizzazioni (ultimi 30 giorni)
i have program in matlab where in command window i give data as a input and after select method it give me output(sum,mult etc)
i want to do the same by gui. a 'edit text' where i can enter number as a input an push button which increment or decrement the input and a push button show the output in the same edit text box.

Risposte (2)

Geoff Hayes
Geoff Hayes il 28 Gen 2015
Check http://www.mathworks.com/discovery/matlab-gui.html for some details (with videos) on how to build a GUI. In your case, it seems clear - use GUIDE to create a GUI with an edit text box and a push button. If the former is named edit1 and the latter is named pushbutton1 then all you need to do is define the callback for the push button. Something like
% --- Executes on button press in pushbutton1.
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 the value from the text box and convert to a number
val = str2num(char(get(handles.edit1,'String')));
% do some work using val
It may be that you need two edit text boxes if you are adding, subtracting or multiplying two numbers. Start with something simple and see what happens!
  2 Commenti
Daniel Liberman
Daniel Liberman il 14 Mar 2020
Hi,
What do I need to do if I want to get a numeric vector from the user in the edit text box?
Geoff Hayes
Geoff Hayes il 14 Mar 2020
Daniel - are the numbers in the text box separated by spaces or commas? If spaces, why can't str2num be used (which should create a numeric array)?

Accedi per commentare.


Saleh Abumousa
Saleh Abumousa il 14 Dic 2020
in gui guide editor text use to

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by