Borrar filtros
Borrar filtros

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

5 visualizaciones (últimos 30 días)
acun67 acu
acun67 acu el 27 de En. de 2015
Respondida: Saleh Abumousa el 14 de Dic. de 2020
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.

Respuestas (2)

Geoff Hayes
Geoff Hayes el 28 de En. de 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 comentarios
Daniel Liberman
Daniel Liberman el 14 de Mzo. de 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 el 14 de Mzo. de 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)?

Iniciar sesión para comentar.


Saleh Abumousa
Saleh Abumousa el 14 de Dic. de 2020
in gui guide editor text use to

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by