How to get user input from an edit text field

4 visualizaciones (últimos 30 días)
Timothy
Timothy el 13 de Jun. de 2013
In Matlab GUI, without using GUIDE tools, I am trying to get user input out of an edit text field and use it in a different function. This user input will be used as parameters for a graph that will be define in the other function. I have tried doing this by using the handle of the edit text field and the error non existant field is returned to me. How do I get around this error, and Is there any way that this can be done?
  2 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 13 de Jun. de 2013
post the part of your code causing error
Matt Kindig
Matt Kindig el 13 de Jun. de 2013
I think you want to do something like this:
value = str2double(get(objectHandle, 'String'));

Iniciar sesión para comentar.

Respuestas (1)

Evan
Evan el 13 de Jun. de 2013
Editada: Evan el 13 de Jun. de 2013
In the function that creates your uicontrols, do you ever save your handles structure after creating the editbox? Example:
function mygui
handles.f = figure; %create figure
handles.edit = uicontrol('style','edit',...
'callback',{@my_callback}); %create editbox
guidata(handles.f,handles) %save handles structure to figure
function my_callback(h,evt)
That's the just about only thing I can think of that would be causing the field to be missing whenever you pass the handles structure to your callback function and attempt to access the string in the editbox.

Categorías

Más información sobre Interactive Control and Callbacks 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