extracting info from edit text gui
8 次查看(过去 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...
0 个评论
回答(1 个)
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 ;-)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!