extracting info from edit text gui

조회 수: 8 (최근 30일)
sundeep cheruku
sundeep cheruku 2011년 6월 24일
[EDIT: 20110625 - reformat - WDR]
Please help me with this
function [] = clear_edit_example()
% Show how to clear and editbox string when cursor is placed over it.
S.fh = figure('units','pixels',...
'position',[500 500 300 50],...
'menubar','none',...
'numbertitle','off',...
'name','clear_edit_example',...
'resize','off');
S.ed = uicontrol('style','edit',...
'units','pixels',...
'position',[10 10 280 30],...
'fontsize',14,...
'string','Enter Value');
set(S.fh,'windowbuttonmotionfcn',{@fh_bmfcn,S})
This is the code and i want to use the data of editbox externally for some other purpose... someone please help me with this...

답변 (1개)

Arturo Moncada-Torres
Arturo Moncada-Torres 2011년 6월 24일
To extract the data (text) from the edit box, you will need something more or less like this:
% Get the string from the editText box.
myText = get(S.ed, 'String');
EDIT
When you run a GUI, the variables' scope is only within the GUI. If you want to be able to manipulate that variable later, save the variable into a .mat file and load it later. For example:
% Get the string.
myText = get(S.ed, 'String');
% Save the variable into a .mat file.
save('myTextVariable', 'myText');
Later, to recover it:
% Load the variable for later use.
load('myTextVariable', 'myText');
Try it and let me know if it works ;-)
  댓글 수: 2
sundeep cheruku
sundeep cheruku 2011년 6월 24일
inside the function the value works fine... but when i check in the matlab prompt.. it shows 'text' is undefined variable..
Arturo Moncada-Torres
Arturo Moncada-Torres 2011년 6월 24일
See the edit please ;-)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by