I am using the ginput to create a rectangle and I want the X axis of the rectangle to show in my edit text box. i have tried the code below but unfortunately it still remains unchanged.
function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global hrect %makes the button known to other variables
global xminglobal ymin[x,y] = ginput(2)xmin = min(x)xmax = max(x)ymin = min(y)ymax = max(y)width = xmax - xmin %draws the width which is the diff b/w xman n xmin
height = ymax - ymin %draws the height
hrect = rectangle('Position', [xmin ymin width height]) %creates the rectangle with 2 axes, x n y.
set(hrect,'FaceColor',[1 0 0]) %sets the fill color to red
a = get(handles.pushbutton1,'String',num2str(xmin)) set(handles.rectXedit,'String',a)
This code below shows the edit text function
function rectXedit_Callback(hObject, eventdata, handles)% hObject handle to rectXedit (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 rectXedit as text
% str2double(get(hObject,'String')) returns contents of rectXedit as a double
global xmin %disp(xmin)
%get(hObject,'String',num2str(xmin))
Please How can I show this in the text edit box. Thanks
Best Answer