Tuesday, February 21, 2012

GUI in MATLAB 2

Last time I showed you how to make a figure with a figure handle.

Now let's open a figure with whatever size you want in whatever position you need.

Type like this
Then this shows up

Do you see how that 'Position' array puts your figure in a place with size you want? The first two numbers are the "position in terms of # of pixels" of the bottom left corner of the figure in respect to the bottom left corner of your monitor screen.
The next two numbers are the width and height (in pixels) of the figure. Ah~

Now type this

Now the figure moved and changed the size. This is why we're keeping track of the figure handle instead of just drawing figure. The figure handle, F1, let you make changes and adjustment whenever needed. Using the figure handle you can save important data to the hidden storage for later use.
"set(something something)" is how you change settings on the object that belongs to the handle.
Oh~! That's right.

As I mentioned in the previous post, plots can have handles as well. Like "P1=plot(x,y,'*')". Then using this plot handle you can change it's color, thickness, line shape, etc.
I'll show you this in later posts.

Play with it a little more until you get used to the idea of this 'Position'.
Later when we put buttons and text boxes we'll use 'Position' again.

I'll show you how to change background colors and get rid of menus next time.

No comments:

Post a Comment