| Contents | Index |
setpixelposition(handle,position)
setpixelposition(handle,position,recursive)
setpixelposition(handle,position) sets the position of the component specified by handle, to the specified position relative to its parent. position is a four-element vector that specifies the location and size of the component: [pixels from left, pixels from bottom, pixels across, pixels high].
setpixelposition(handle,position,recursive) sets the position as above. If Boolean recursive is true, the position is set relative to the parent figure of handle.
This example first creates a push button within a panel.
f = figure('Position',[300 300 300 200]);
p = uipanel('Position',[.2 .2 .6 .6]);
h1 = uicontrol(p,'Style','PushButton','Units','normalized',...
'String','Push Button','Position',[.1 .1 .5 .2]);
![]()
The example then retrieves the position of the push button and changes its position with respect to the panel.
pos1 = getpixelposition(h1); setpixelposition(h1,pos1 + [10 10 25 25]);
![]()
getpixelposition | uicontrol | uipanel

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |