edit button in matlab

조회 수: 24 (최근 30일)
ikenna
ikenna 2013년 11월 2일
댓글: Image Analyst 2013년 11월 4일
please i need help in making the edit button show on the axes. I parse the text into the button and I am trying to code it. this is my code below. I am new to this site :)
thanks...
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=get(handles.edit1,'String')
set(handles.edit1,'String',a)
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 2일
Your code is not doing anything, What is your exact problem ?
ikenna
ikenna 2013년 11월 3일
I want the text in the text bar to show in the axes when the button is pushed.. this is my code
function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double %a = get(hObject, 'String');
% --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
a=get(handles.edit1,'String') set(handles.edit1,'String',a)
thanks

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

채택된 답변

Image Analyst
Image Analyst 2013년 11월 3일
You say "I want the text in the text bar to show in the axes when the button is pushed."
I don't know what a text bar is, but I assume you mean your edit text field/box. I also will assume you have an axes called axes1 that has a range of 0-10 in the x direction and 0-10 in the y direction. So, just make your pushbutton4 callback look like this.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get the text in the edit box:
editText = get(handles.edit1,'String')
% Make it show up in the axes at location 2,4:
text(2, 4, editText);
  댓글 수: 2
ikenna
ikenna 2013년 11월 4일
thank you so very much... I really appreciate.
Image Analyst
Image Analyst 2013년 11월 4일
If I've solved it for you, then please mark the Answer as Accepted, otherwise let's figure out how to get it working.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by