File Exchange

image thumbnail


version 1.0 (1.34 KB) by

Query any number of graphics object properties at once using the get command.



View License

This function is aimed at reducing redundant typing and taking a few lines out of your scripts. If you want to get any number n object properties (hence, nget) at once use

[varargout] = nget(h,varargin)

EXAMPLE: Reduce the following five lines of code down to one:
xlim = get(gca,'xlim');
ylim = get(gca,'ylim');
zlim = get(gca,'zlim');
font = get(gca,'fontname');
kids = get(gca,'children');

Using nget:
[xlim,ylim,zlim,font,kids] = nget(gca,'xlim','ylim','zlim','fontname','children');

Comments and Ratings (2)

Chad Greene

Chad Greene (view profile)

Sven, that's brilliant! I think I may just adopt your method because scripts are always more portable and sharable when they don't rely on custom functions. Thanks for the suggestion!


Sven (view profile)

Chad, the situation wasn't quite as bad as your example described. You can get all those props in two lines rather than 5:

props = get(gca,{'xlim','ylim','zlim','fontname','children'});
[xlim,ylim,zlim,font,kids] = props{:};

You may at least want to update the internals of your function to use this syntax rather the loop, which can become costly if you try getting lots of props at once using your nget().

MATLAB Release
MATLAB 8.0 (R2012b)
Tags Add Tags

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video