function pushbutton3_Callback(hObject, eventdata, handles) p=getpixelposition(hObject); set(handles.uipushtool1,'UserData',p); % get the pushbutton position and put it in the User data of the uipushtool1
% --------------------------------------------------------------------
function uipushtool1_ClickedCallback(hObject, eventdata, handles)[x,map]=imread('NC.PNG');I2=imresize(x, [40 100]); p=get(hObject,'UserData') % get the position of the pushbutton back from User data of the uipushtool1
h=findobj('position',p) % Find object which has the positon stored in the userdata (P)
set(h,'CData',I2) % put my picture in the object h specified by its position
MATLAB: Hello i am working on GUI and i wrote a simple code that get the position of the pushbutton once it is pressed then send it thruogh the UserData property to the uipushtool which will display a resized picture on the pushbutton CData
gui userdata cdata
Best Answer