# UIGETVARIABLES: A variable selector widget for building GUIs and apps

tvar = uigetvariables({'Pick a scalar:','Pick a vector:','Pick a matrix:'},[],[],[0 1 2]);
and uigetvariables will create a custom selection GUI that facilitates the selection: I can also specify more advanced criteria for selections; Scott's clever utility will tell the user which variables are acceptable, and will indicate when no workspace variables fit the bill. The net result: it was really easy to modify my code to allow the user to pick an MxN or MxNx3 (RGB) image:
validateimage = @(im) (isnumeric(im) || islogical(im)) &&(ndims(im)==2 && ~any(size(im)==2) || (ndims(im)==3&&size(im,3)==3));
img = uigetvariables(prompts,inputstring,validateimage);

Published with MATLAB® 8.0

|