how to read in the static text?

답변 (2개)

TAB
TAB 2012년 1월 31일

0 개 추천

In your callback function, where you have access to handles structure
StrVal = get(handles.text1,'String');
Anywhere else
th=findobj('Style','text','-and','Tag','text1'); % Find handle of static text
get(th,'String') % Read value
text1 is your static text.
[EDITED] To copy the value of edit text into static text
function edit1_Callback(hObject, eventdata, handles)
str = get(hObject,'String');
set(handles.text1,'String',str);
When you will hit the 'ENTER' key after entering some string in edit text, static text value will also be updated.

댓글 수: 7

norfaizayu
norfaizayu 2012년 1월 31일
your callback function means?at static text do not has callback function.
norfaizayu
norfaizayu 2012년 1월 31일
i mean,how can i write in static text?sorry for my fault question.
i want put some value read from edit text,and put to static text.
TAB
TAB 2012년 1월 31일
Use callback function of edit text as shown in EDITED part of above answer.
norfaizayu
norfaizayu 2012년 2월 1일
ok..thanks you.i got it.if i want use at popup menu, i should do condition?
norfaizayu
norfaizayu 2012년 2월 1일
how can i read the select word at popup menu list to view at static text?
Walter Roberson
Walter Roberson 2012년 2월 2일
function popup1_Callback(hObject, eventdata, handles)
idx = get(hObject, 'Value');
if isempty(idx); return; end
entries = cellstr(get(hObject, 'String'));
thisentry = entries{idx};
set(handles.text1, 'String', thisentry);
Zhengyi
Zhengyi 2012년 2월 2일
if the static text is created from GUIDE, it is impossible to get any callback, ie Text1_Callback(hObject,eventdata,handles) is not valid.
I have tried this:
function Plot1_Info_Callback(hObject, eventdata, handles)
handles=guidata(hObject);
guidata(hObject,handles);
It doesn't work and comes up with en error msg:
"Input argument "hObject" is undefined."
Also, findobj('Style','text') gives an Empty matrix: 0-by-1, although I made two blank static texts in GUIDE.
How can I overcome this?
Cheers!

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

Zhengyi
Zhengyi 2012년 2월 2일

0 개 추천

function DrawSignal(original_data,filtered_data,column_index,column_index2)
global Column_No_UI thickness
subplot(2,1,1);
plot(original_data(column_index,:))
subplot(2,1,2);
plot(filtered_data(column_index2,:))
info_1 = sprintf('Plotted from: | original data | Column# %s | Thicknee %s',num2str(Column_No_UI), num2str(thickness));
set(handles.Plot1_Info,'Spring',info_1)
This is what I did, but I finally get an error msg:
??? Undefined variable "handles" or class "handles.Plot1_Info".
Error in ==> UI_Develop_Test_v1_plot>DrawSignal at 223 set(handles.Plot1_Info,'Spring',info_1)

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

태그

질문:

2012년 1월 31일

편집:

2013년 9월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by