extracting info from edit text gui

6 次查看(过去 30 天)
[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
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..

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by