Receiving Data from GUI edit box

조회 수: 1 (최근 30일)
Ashley Hamlin
Ashley Hamlin 2017년 4월 30일
편집: Walter Roberson 2017년 5월 4일
I am having issues with retrieving the information that the user inputs into the GUI. The edit box is as follows.
IP_Adress_Phone=uicontrol('Style','edit','BackgroundColor','white','Units','Normalized','Position',[.1 .1 .4 .1],'String','Enter your phone IP address here',...'Visible','on','Callback',@callbackfn);

답변 (1개)

Kevin Gleason
Kevin Gleason 2017년 5월 3일
Using the code you provided above:
IP_Adress_Phone=uicontrol('Style','edit','BackgroundColor','white',...
'Units','Normalized','Position',[.1 .1 .4 .1],...
'String','Enter your phone IP address here',...
'Visible','on','Callback',@callbackfn);
In order to extract data, you need to define the callback. The callback's first parameter will be a reference to the IP Text Field itself. You can then extract the Text Field's "String" Property.
function callbackfn(hObj, e)
ipAddr = hObj.String;
disp(['ipAddr: ' ipAddr]);
end
Callback's Documentation for reference:

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by