getWidthPixel.m 258 B

12345678910111213
  1. function width = getWidthPixel(h)
  2. %GETWIDTHPIXEL Get the width of a graphical object in pixel
  3. % Input:
  4. % h = graphical object handle
  5. savedUnit = get(h, 'Unit');
  6. set(h, 'Unit', 'pixels');
  7. p = get(h, 'Position');
  8. set(h, 'Unit', savedUnit);
  9. width = p(3);