User`s guide
11 Lay Out a Programmatic GUI
Tip You can provide an empty property name followed by a value when you
call
setprop. Then, the function attempts to assign that value to the property
you choose in the GUI. Call
setprop this way when you know the value you
want to assign, but are unsure of h ow to spell the property name.
Some property values (for example, matrices or cell arrays) can generate long
statements. You can break long commands into continuation lines (
...)to
improve their readability, but it is not necessary to do so.
Combine the
setprop and s etpos functions to set the position of a component
interactively and generate a set command for the new position. Try the
following code, substituting an actual component handle for
object_handle:
setstr = setprop(object_handle,'po s',setpos(object_handle) )
=== Drag out a Position for object_handle
After you drag out a rectangle in the figure, you receive a result that looks
like this statement (but specifies your rectangle), which you can directly paste
into your GUI code file:
setstr = set(hs2,'Position',[38 62 146 239])
View and Run the setprop Function
If you are reading this document in the M ATLAB Help browser, you can
access the
setprop.m doc exa m p le file b y click ing the following links. If yo
u
are reading on the Web or from a PDF, go to the corresponding section in the
MATLAB Help Browser to use the links.
If you intend to modify the code of this example function, first save a cop
yof
its code f ile in your current folder. (You need write access to your curr
ent
folder to save files there.) Click the following links to copy the examp
le files to
your current folder and open them .
1 Clickheretocopythesetprop file to your current folder
2 Type edit setpr op or click here t o open the file in th e MA T L A B Ed itor
If you only want to run the function and inspect its code, follow these steps:
11-68