Matlab_GUI and Graphics Programming FINAL

120
8/11/2019 Matlab_GUI and Graphics Programming FINAL http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 1/120 MATLAB orientation course MATLAB orientation course MATLAB GUI MATLAB GUI And And Graphics Programming Graphics Programming Delivered by Delivered by Dr. Suman Chakraborty Dr. Suman Chakraborty Assistant Professor Assistant Professor Mechanical Engineering Department Mechanical Engineering Department Indian Institute of echnology! "haragpur Indian Institute of echnology! "haragpur

Transcript of Matlab_GUI and Graphics Programming FINAL

Page 1: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 1/120

MATLAB orientation courseMATLAB orientation course

MATLAB GUIMATLAB GUI

AndAnd

Graphics ProgrammingGraphics Programming

Delivered byDelivered by

Dr. Suman ChakrabortyDr. Suman ChakrabortyAssistant ProfessorAssistant Professor

Mechanical Engineering DepartmentMechanical Engineering Department

Indian Institute of echnology! "haragpurIndian Institute of echnology! "haragpur

Page 2: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 2/120

MATLAB orientation courseMATLAB orientation course

Presentation #vervie$Presentation #vervie$

Graphics ProgrammingGraphics Programming

PlotsPlots(2D, 3D etc!(2D, 3D etc!

AnimationsAnimations(mo"ies, sounds etc!(mo"ies, sounds etc!

GUIGUI

Page 3: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 3/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

Basic Plotting: TheBasic Plottin

g: The PlotPlot FunctionFunction

plot (x, y)plot (x, y) plots vector y versus vector x.plots vector y versus vector x.

>> x = [0:0.:!0"#>> x = [0:0.:!0"#

>> y = sin(x)#>> y = sin(x)#

>> plot (x, y)>> plot (x, y)

Page 4: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 4/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

Basic Plotting: TheBasic Plottin

g: The PlotPlot FunctionFunction (cont.)(cont.)

$% & or ' is a atrix, then the vector is plotte$% & or ' is a atrix, then the vector is plotte

versus the ro*s or coluns o% the atrix,versus the ro*s or coluns o% the atrix,

 *hichever line up. *hichever line up.

>> x = [0:0.:!0"#>> x = [0:0.:!0"#

>> y = [ sin(x)# cos(x) "#>> y = [ sin(x)# cos(x) "#

>> plot (x, y)>> plot (x, y)

+in(x)

os(x)

Page 5: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 5/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

-ultiple plots on the sae %igure-ulti

ple plots on the sae %igure

-etho !-etho !

>> x = [0:0.:!0"#>> x = [0:0.:!0"#

>> y = sin(x)# = cos(x)#>> y = sin(x)# = cos(x)#>> plot (x, y, x, )>> plot (x, y, x, )

-etho -etho

>> plot (x,y), hol on>> plot (x,y), hol on>> plot(x,), hol o%%>> plot(x,), hol o%%

hold onhold on  hols the current plot anhols the current plot an

all axis properties so thatall axis properties so thatsu/seuent graphing coanssu/seuent graphing coans

a to the existing graph.a to the existing graph.

hold o##hold o## returns to the e%ault oereturns to the e%ault oe

 *here/y P12T coans erase *here/y P12T coans erase

the previous plots an reset all axisthe previous plots an reset all axis

properties /e%ore ra*ing ne* plots.properties /e%ore ra*ing ne* plots.

Page 6: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 6/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

3leents o% a plot *ino*3leents o% a

plot *ino* TitleTitle

1egen1egen

4ri lines4ri lines

' la/el' la/el

x la/elx la/el

5xis /ox5xis /ox

Page 7: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 7/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

5ing title an axis la/els5ing title an axis la/els

>> xla/el(6x6), yla/el(6y6)#>> xla/el(6x6), yla/el(6y6)# >> title([6sin an cos Functions6")#>> title([6sin an cos Functions6")#

Page 8: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 8/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

4ris an axis /ox4ris an axis /ox

>> gri on>> gri on >> /ox o%%>> /ox o%%

Turns o## theTurns o## the

a$es %o$a$es %o$

Page 9: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 9/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

1inestyles, ar7ers an colors1inestyles, ar7ers an colorsSymbolSymbol ColorColor SymbolSymbol markermarker SymbolSymbol 'inestyle'inestyle

bb   blueblue   ..   pointpoint   --   solidsolid

gg   greengreen   oo   circlecircle   ::   dotteddotted

rr   redred   xx   x-markx-mark   -.-.   dashdotdashdot

cc   cyancyan   ++   plusplus

mm   magentamagenta   **   starstar

yy   yellowyellow   ss   squaresquare

kk   blackblack   dd   diamonddiamond

vv   triangle (down)triangle (down)

  triangle (up)triangle (up)

!!   triangle (le"t)triangle (le"t)

##   triangle (right)triangle (right)

pp   oentagramoentagram

hh   hexagramhexagram

3xaple:3xaple:plot (x, y, 8rs9.6)plot (x, y, 8rs9.6) plots a replots a re

ashot line *ith aashot line *ith a

suare at each ata pointsuare at each ata point

Page 10: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 10/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

5ing text an text %oratting5ing text an text %orattingtext (x, y, 8string)text (x, y, 8string) as the text in the uotes to location (x, y).as the text in the uotes to location (x, y).

gtext (8string)gtext (8string) isplays the graph *ino*, puts up a cross9hair, an *aitsisplays the graph *ino*, puts up a cross9hair, an *aits

%or a ouse /utton or 7ey/oar 7ey to /e presse.%or a ouse /utton or 7ey/oar 7ey to /e presse.

;i%%erent text<text /ox appearances can /e set using the %ollo*ing;i%%erent text<text /ox appearances can /e set using the %ollo*ing

properties:properties:

Bac7grounolorBac7grounolor:: +ets the color o% text extent rectangle.+ets the color o% text extent rectangle.

>> gtext (8string, Bac7grounolor,y)>> gtext (8string, Bac7grounolor,y)

3geolor3geolor: +ets the color o% ege ra*n aroun text extent rectangle.: +ets the color o% ege ra*n aroun text extent rectangle.

  >> gtext (8string, 3geolor,r)gtext (8string, 3geolor,r)

1ine+tyle1ine+tyle

:: +tyle o% the rectangle6s ege line.+tyle o% the rectangle6s ege line.

1ineith1ineith:: ith o% the rectangle6s ege lineith o% the rectangle6s ege line

>> gtext (8string, 1ine+tyle, :, 1ineith, )>> gtext (8string, 1ine+tyle, :, 1ineith, )

Bac7groun colorBac7groun color

is set to yello*is set to yello*

3ge color is set3ge color is set

to yello*to yello*

+ets line style to ote+ets line style to ote +ets line *ith to +ets line *ith to

A sample te$t %o$ a#ter &riting the a%o"e linesA sample te$t %o$ a#ter &riting the a%o"e lines

Page 11: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 11/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

$ncluing 4ree7 letters an +pecial characters$ncluing 4ree7 letters an +pecial characters

3xaple:3xaple: 6?<partial@?<phi@A?<partial@t = ?<na/la@?<phi@86?<partial@?<phi@A?<partial@t = ?<na/la@?<phi@8 isplays the stringisplays the string

Page 12: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 12/120

MATLAB orientation courseMATLAB orientation course

$o%Dimensional &raphics$o%Dimensional &raphics

+oe iportant ; plotting coans+oe iportant ; plotting coans

  CCloglogloglogD: graph *ith logarithic scales %or /othD: graph *ith logarithic scales %or /oth

axes.axes.

  CCseilogxseilogxD: graph *ith a logarithic scale %or x9D: graph *ith a logarithic scale %or x9axis an a linear scale %or y9axis.axis an a linear scale %or y9axis.

  CCseilogyseilogyD: graph *ith a logarithic scale %or y9D: graph *ith a logarithic scale %or y9

axis an a linear scale %or x9axis.axis an a linear scale %or x9axis.

  CCplotyyplotyyD: graph *ith y9tic7 la/els on the le%t anD: graph *ith y9tic7 la/els on the le%t an

right sie.right sie.

Page 13: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 13/120

MATLAB orientation courseMATLAB orientation course

Using the Propert' ditor)Using the Propert' ditor)

e *ant to a7e:e *ant to a7e:

Titles an la/els /igger.Titles an la/els /igger.

1ines thic7er.1ines thic7er.

olors ore contrasting.olors ore contrasting.

;ata points.;ata points.

1egen.1egen.

$o%Dimensional &raphics$o%Dimensional &raphics

Page 14: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 14/120

MATLAB orientation courseMATLAB orientation course

#pen the Property Editor#pen the Property Editor

Page 15: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 15/120

MATLAB orientation courseMATLAB orientation course

Edit (igure PropertiesEdit (igure Properties

Page 16: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 16/120

MATLAB orientation courseMATLAB orientation course

dit A$es Propertiesdit A$es Properties

3it la/el

hange la/el text

style, %ont, color etc

hange axis color

hange axis

location

+*itch gris 8on

an 8o%%

+et axis liits

+et axis tic7s

+et axis la/els

hoose scaletype: linear, log#

noral, reverse

lic7 here %orore help

Page 17: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 17/120

MATLAB orientation courseMATLAB orientation course

dit Line Propertiesdit Line Properties

3it line style

hange line *ith

3it line color

3it ar7er style

3it ar7er sie

3it ar7er

ege color

3it ar7er

%ace color

5 saple suare

ar7er o% ege

color /lac7, an

%ace color cyan

Page 18: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 18/120

MATLAB orientation courseMATLAB orientation course

A )etter%'ooking (igureA )etter%'ooking (igure

Page 19: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 19/120

MATLAB orientation courseMATLAB orientation course

Insert 'egendInsert 'egend

Page 20: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 20/120

MATLAB orientation courseMATLAB orientation course

Edit 'egend PropertiesEdit 'egend Properties

3it %ont

properties

Page 21: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 21/120

MATLAB orientation courseMATLAB orientation course

(inal plot(inal plot

Page 22: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 22/120

MATLAB orientation courseMATLAB orientation course

Multiple figures in the same $indo$Multiple figures in the same $indo$

su/plot (,,E)su/plot (,,E) ivies the %igure *ino* into parts in %irstivies the %igure *ino* into parts in %irst

irection an parts in secon irectionirection an parts in secon irection

ivisions ivisions

)ivisions

)ivisions

su/plot(,,!)

su/plot(,,)

su/plot(,,)

su/plot(,,)

su/plot(,,G)

su/plot(,,H)

Page 23: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 23/120

MATLAB orientation courseMATLAB orientation course

Some speciali*ed +D plotsSome speciali*ed +D plots

Bar GraphBar Graph(%ar, *stac+ed!(%ar, *stac+ed! 3D -ori.ontal Bar Graph3D -ori.ontal Bar Graph

(Bar3h!(Bar3h! -istogram-istogram(hist!(hist!

Area PlotArea Plot

(area!(area!3D pie chart3D pie chart

(pie3!(pie3!Polar -istogramPolar -istogram

(rose!(rose!

Page 24: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 24/120

MATLAB orientation courseMATLAB orientation course

hree%Dimensional &raphicshree%Dimensional &raphics

; line plot; line plot

>> t = linspace(0,0Ipi)#>> t = linspace(0,0Ipi)#

>> plot(sin(t),cos(t),t,61ineith6,)>> plot(sin(t),cos(t),t,61ineith6,)

>> gri on>> gri on>> xla/el(6sin(t)6,6Font+ie6,!)#>> xla/el(6sin(t)6,6Font+ie6,!)#

>> yla/el(6cos(t)6,6Font+ie6,!)#>> yla/el(6cos(t)6,6Font+ie6,!)#

>> la/el(6t6,6Font+ie6,!)#>> la/el(6t6,6Font+ie6,!)#

>> title(6Jelix6,6Font+ie6,!)>> title(6Jelix6,6Font+ie6,!)

Page 25: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 25/120

Page 26: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 26/120

MATLAB orientation courseMATLAB orientation course

hree%Dimensional &raphicshree%Dimensional &raphics

$n the su/seuent iscussions *e *ill %reuently use the %unction$n the su/seuent iscussions *e *ill %reuently use the %unction8pea7s. 8pea7s is a saple %unction o% t*o varia/les, o/taine /y8pea7s. 8pea7s is a saple %unction o% t*o varia/les, o/taine /y

translating an scaling 4aussian istri/utions. There are severaltranslating an scaling 4aussian istri/utions. There are several

variants o% the calling seuence:variants o% the calling seuence:

= pea7s# = pea7s# K prouces LxL atrixK prouces LxL atrix

= pea7s (n)# = pea7s (n)# K prouces nxn atrixK prouces nxn atrix = pea7s (v)# = pea7s (v)# K evaluates %unction pea7s at points speci%ie /y vK evaluates %unction pea7s at points speci%ie /y v

= pea7s (x, y) = pea7s (x, y)  K evaluates %unction pea7s at points speci%ie /y (x, y)K evaluates %unction pea7s at points speci%ie /y (x, y)

>> [x,y," = pea7s#>> [x,y," = pea7s#

>> plot(x,y,)>> plot(x,y,)

Mote:Mote: pea7s *ith no output arguentspea7s *ith no output arguents

prouce sur% plot o% the result.prouce sur% plot o% the result.

Page 27: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 27/120

MATLAB orientation courseMATLAB orientation course

Contour plotsContour plots

FunctionFunction ontourontour  reates contour plotsreates contour plots 

>> contour (pea7s)>> contour (pea7s)

Page 28: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 28/120

MATLAB orientation courseMATLAB orientation course

Contour plotsContour plots

FunctionFunction ontourontour (cont.)(cont.) 

>> contour (pea7s,0)>> contour (pea7s,0)

+peci%ies the nu/er

o% contour

Page 29: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 29/120

MATLAB orientation courseMATLAB orientation course

Contour plotsContour plots

$nserting contour la/els$nserting contour la/els 

>> [c,h" = contour (pea7s)#>> [c,h" = contour (pea7s)#

>> cla/el (c, h)>> cla/el (c, h)

>> color/ar#>> color/ar#

+tores the+tores the

contour atrixcontour atrix

+tores the hanles to+tores the hanles toline or patch o/Nectsline or patch o/Nects

Page 30: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 30/120

MATLAB orientation courseMATLAB orientation course

Contour plotsContour plots

FunctionFunction ontourontour 

>> contour (pea7s,0)>> contour (pea7s,0)

ontours are ra*n at theirontours are ra*n at their

corresponing level.corresponing level.

Page 31: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 31/120

MATLAB orientation courseMATLAB orientation course

Contour plotsContour plots

;ra*ing a +ingle ontour 1ine at a ;esire 1evel;ra*ing a +ingle ontour 1ine at a ;esire 1evel

>> contour (pea7s, [! !")>> contour (pea7s, [! !") >> contour (pea7s, [! !")>> contour (pea7s, [! !")

Page 32: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 32/120

MATLAB orientation courseMATLAB orientation course

,uiver plots,uiver plots

>> [&, ', O" = pea7s([9:0.:")#>> [&, ', O" = pea7s([9:0.:")#

>> contour (&, ', O, 0)#>> contour (&, ', O, 0)#>> [, Q" = graient (O, 0.)#>> [, Q" = graient (O, 0.)#

>> hol on>> hol on

>> uiver (&, ', , Q)>> uiver (&, ', , Q)

The uiver %unction sho*s vectorsThe uiver %unction sho*s vectors

at given points in t*o9iensionalat given points in t*o9iensional

space.space.

FunctionFunction RuiverRuiver 

+pacing /et*een points+pacing /et*een points

in each irectionin each irection

3valuates approxiate3valuates approxiate

nuerical graientnuerical graient

Page 33: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 33/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction -esh-esh  reates 9; esh *ith re%erence planereates 9; esh *ith re%erence plane 

>> esh(pea7s,61ineith6,!)>> esh(pea7s,61ineith6,!)

Page 34: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 34/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction -eshc-eshc  o/ination o% esh A contour ploto/ination o% esh A contour plot

>> eshc (pea7s)>> eshc (pea7s)

Page 35: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 35/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction -esh-esh  4enerate the curtain plot4enerate the curtain plot 

>> esh (pea7s)>> esh (pea7s)

Page 36: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 36/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction JienJien  Seove hien lines %ro a esh plotSeove hien lines %ro a esh plot

>> hien o%%>> hien o%% >> hien on>> hien on

Page 37: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 37/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction sur%sur%  4enerate 9; shae sur%ace graph4enerate 9; shae sur%ace graph >> sur% (pea7s)>> sur% (pea7s)

Page 38: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 38/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction sur%csur%c  o/ination sur% A contour ploto/ination sur% A contour plot >> sur%c (pea7s)>> sur%c (pea7s)

Page 39: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 39/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction sur%lsur%l  +ur%ace plot *ith colorap9/ase lighting+ur%ace plot *ith colorap9/ase lighting

>> sur%l (pea7s)>> sur%l (pea7s)

>> shaing(6interp6)>> shaing(6interp6)

e shall tal7e shall tal7

a/out 8shainga/out 8shaing

in later sliesin later slies

Page 40: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 40/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction *ater%all *ater%all 

>> *ater%all (pea7s)>> *ater%all (pea7s)

 *ater%all(...) is the sae as *ater%all(...) is the sae as

esh(...) except that the colunesh(...) except that the colun

lines o% the esh are not ra*nlines o% the esh are not ra*n

Page 41: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 41/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction sur%norsur%nor  [nx, ny, n" = sur%nor()[nx, ny, n" = sur%nor()  returns the sur%ace noralreturns the sur%ace noral

coponents %or the sur%ace O.coponents %or the sur%ace O.

  ithout le%than arguents, sur%nor() plots theithout le%than arguents, sur%nor() plots the

sur%ace *ith the norals eanating %ro it.sur%ace *ith the norals eanating %ro it.

>> sur%nor(pea7s(0))>> sur%nor(pea7s(0))

Page 42: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 42/120

MATLAB orientation courseMATLAB orientation course

Surface and Mesh plotsSurface and Mesh plots

FunctionFunction pcolorpcolor  Pseuocolor plotPseuocolor plot

5 pseuocolor plot is a rectangular array o% cells *ith5 pseuocolor plot is a rectangular array o% cells *ith

colors eterine /y 8c, *here 8c is passe ascolors eterine /y 8c, *here 8c is passe as

arguent to %unction pcolor as: pcolor(c).arguent to %unction pcolor as: pcolor(c).

>> pcolor(pea7s)>> pcolor(pea7s)

>> shaing interp>> shaing interp

>> color/ar>> color/ar

Page 43: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 43/120

MATLAB orientation courseMATLAB orientation course

-andle &raphics-andle &raphics

4raphics in -5T15B consist o%4raphics in -5T15B consist o% objects:objects:root, figure, axes, image, line, patch,root, figure, axes, image, line, patch,rectangle, surface, text, light rectangle, surface, text, light 

4raphics prograing in -5T15B contains4raphics prograing in -5T15B contains

reating 2/Nectsreating 2/Nects

+etting 2/Nect Properties pon reation+etting 2/Nect Properties pon reation

2/taining an 2/Nects Janles2/taining an 2/Nects Janles

no*ing 2/Nect Propertiesno*ing 2/Nect Properties

-oi%ying 2/Nect Properties-oi%ying 2/Nect PropertiesU singsing Command LineCommand Line

U singsing Property EditorProperty Editor (We have already discussed(We have already discussed

Page 44: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 44/120

MATLAB orientation courseMATLAB orientation course

&raphics #bects&raphics #bects/oot

o%0ect

1igure

o%0ect

UIontrol

o%0ects

UIMenu

o%0ects

A$es o%0ect

1igure

o%0ect

ur#ace

o%0ect

Line

o%0ects

Te$t

o%0ects

UIontrol

o%0ects

UIMenu

o%0ects

A$es o%0ect

1igure

o%0ect

Page 45: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 45/120

MATLAB orientation courseMATLAB orientation course

!.!. pon reationpon reation>> hVline = plot(xVata, yVata, ...)>> hVline = plot(xVata, yVata, ...)

.. tility Functionstility Functions

00 9 root o/Nect hanle9 root o/Nect hanle

  gc%gc% 9 current %igure hanle9 current %igure hanle

gcagca 9 current axis hanle9 current axis hanle

  gcogco 9 current o/Nect hanle9 current o/Nect hanle

.. F$M;2BWF$M;2BW>> hVo/N = %ino/N(hVparent, 6Property6, 6Qalue6, ...)>> hVo/N = %ino/N(hVparent, 6Property6, 6Qalue6, ...)

#btaining an #bect/s -andle#btaining an #bect/s -andle

De#ault 4 5 (root o%0ect!

Page 46: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 46/120

MATLAB orientation courseMATLAB orientation course

Modifying #bect PropertiesModifying #bect Properties

2/taining a list o% current properties:2/taining a list o% current properties:

>> get (hVo/Nect)>> get (hVo/Nect)

2/taining a list o% setta/le properties:2/taining a list o% setta/le properties:

>> set (hVo/Nect)>> set (hVo/Nect)

-oi%ying an o/Nects properties-oi%ying an o/Nects properties

sing oan 1inesing oan 1ine

>>set (hVo/Nect,6PropertyMae6,6Me*VQalue6,...)>>set (hVo/Nect,6PropertyMae6,6Me*VQalue6,...)

sing Property 3itorsing Property 3itor

Page 47: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 47/120

MATLAB orientation courseMATLAB orientation course

Modifying #bect PropertiesModifying #bect Properties

3xaple:3xaple:

Plot the %unctionPlot the %unction

>> x = linspace(0,Ipi,!00)#>> x = linspace(0,Ipi,!00)#

>> y = sin(x)#>> y = sin(x)#

>> h = plot(x,y)#>> h = plot(x,y)#

Page 48: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 48/120

MATLAB orientation courseMATLAB orientation course

Modifying #bect PropertiesModifying #bect Properties

3xaple:3xaple:

2/tain the list o% current properties2/tain the list o% current properties

>> get(h)>> get(h) lipping = onlipping = on

reateFcn =reateFcn =

;eleteFcn =;eleteFcn =

Busy5ction = ueueBusy5ction = ueueJanleQisi/ility = onJanleQisi/ility = on

JitTest = onJitTest = on

$nterrupti/le = on$nterrupti/le = on

Parent = [!0!.00!"Parent = [!0!.00!"

+electe = o%%+electe = o%%

+electionJighlight = on+electionJighlight = on

Tag =Tag =

Type = lineType = line

$ontext-enu = [ "$ontext-enu = [ "

ser;ata = [ "ser;ata = [ "

Qisi/le = onQisi/le = on

olor = [0 0 !"olor = [0 0 !"

3rase-oe = noral3rase-oe = noral

1ine+tyle = 91ine+tyle = 91ineith = [0.G"1ineith = [0.G"

-ar7er = none-ar7er = none

-ar7er+ie = [H"-ar7er+ie = [H"

-ar7er3geolor = auto-ar7er3geolor = auto

-ar7erFaceolor = none-ar7erFaceolor = none

&;ata = [ (! /y !00) ou/le array"&;ata = [ (! /y !00) ou/le array"

';ata = [ (! /y !00) ou/le array"';ata = [ (! /y !00) ou/le array"

O;ata = [ "O;ata = [ "

Being;elete = o%%Being;elete = o%%

Button;o*nFcn =Button;o*nFcn =

hilren = [ "hilren = [ "

Page 49: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 49/120

MATLAB orientation courseMATLAB orientation course

Modifying #bect PropertiesModifying #bect Properties

3xaple:3xaple:

-oi%y the o/Nect properties-oi%y the o/Nect properties

>> set(h,6olor6,6r6,61ine+tyle6,6996,61ineith6,[")>> set(h,6olor6,6r6,61ine+tyle6,6996,61ineith6,[")

>> set(gca,6Box6,6o%%6,6&olor6,6/6,6'olor6,6/8)#>> set(gca,6Box6,6o%%6,6&olor6,6/6,6'olor6,6/8)#

>> set(gca,6FontMae6,6Ties Me* Soan6,6Font+ie6,!,6Fonteight6,6/ol6)>> set(gca,6FontMae6,6Ties Me* Soan6,6Font+ie6,!,6Fonteight6,6/ol6)

Page 50: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 50/120

MATLAB orientation courseMATLAB orientation course

Shading and ColormapShading and Colormap

+haing+haing

The shaing %unction controls the color shaing o%The shaing %unction controls the color shaing o%

sur%ace an patch graphics o/Nects.sur%ace an patch graphics o/Nects.

shaing %latshaing %lat::  each esh line segent an %ace has aeach esh line segent an %ace has a

constant color eterine /y the color value at the enconstant color eterine /y the color value at the enpoint o% the segent or the corner o% the %ace that haspoint o% the segent or the corner o% the %ace that has

the sallest inex or inices.the sallest inex or inices.

shaing %aceteshaing %acete::  %lat shaing *ith superipose /lac7%lat shaing *ith superipose /lac7

esh lines. This is the e%ault shaing oe.esh lines. This is the e%ault shaing oe.

shaing interpshaing interp:: varies the color in each line segent anvaries the color in each line segent an

%ace /y interpolating the colorap inex or true color%ace /y interpolating the colorap inex or true color

value across the line or %ace.value across the line or %ace.

Page 51: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 51/120

MATLAB orientation courseMATLAB orientation course

Shading and ColormapShading and Colormap

>> sphere>> sphere

>> axis suare>> axis suare

>> shaing %lat>> shaing %lat

>> title(6Flat +haing6)>> title(6Flat +haing6)

>> sphere>> sphere

>> axis suare>> axis suare

>> shaing %acete>> shaing %acete>> title(6Facete +haing6)>> title(6Facete +haing6)

>> sphere>> sphere

>> axis suare>> axis suare

>> shaing interp>> shaing interp>> title(6$nterpolate +haing6)>> title(6$nterpolate +haing6)

shaing %latshaing %lat shaing %aceteshaing %acete shaing interpshaing interp

+haing+haing

Page 52: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 52/120

MATLAB orientation courseMATLAB orientation course

Shading and ColormapShading and Colormap

olorapolorap5utun5utun

BoneBone

olorcu/eolorcu/e

oolool

opperopper

FlagFlag4ray4ray

JotJot

JsvJsv

WetWet

1ines1ines

Pin7Pin7

PrisPris+pring+pring

+uer+uer

hitehite

interinter

>> [x,y,"=sphere(G0)#>> [x,y,"=sphere(G0)#

>> sur%l(x,y,)>> sur%l(x,y,)

>> shaing interp>> shaing interp

>> axis suare>> axis suare

>> colorap(gray)>> colorap(gray)

Gra'Gra'

+oe other coloraps+oe other coloraps

opperopper pringpring -ot-ot

Page 53: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 53/120

MATLAB orientation courseMATLAB orientation course

0ie$%points! Camera and 'ighting0ie$%points! Camera and 'ighting

Qie*pointQie*point

TheThe vie*vie*  coan speci%iescoan speci%ies

the vie*point /y e%iningthe vie*point /y e%ining

aiuth an elevation *ithaiuth an elevation *ith

respect to the axis origin. Therespect to the axis origin. The

%igure illustrates the t*o%igure illustrates the t*o

angles.angles.

-5T15B e%ault values:-5T15B e%ault values:

; plots: 5iuthal = 0X, 3levation = L0X; plots: 5iuthal = 0X, 3levation = L0X

; plots:; plots: 5iuthal = 9Y.GX, 3levation = 0X5iuthal = 9Y.GX, 3levation = 0X

3xaple:3xaple: vie*(!Z0,0)vie*(!Z0,0) changes the 5iuthal angle to !Z0 X,changes the 5iuthal angle to !Z0 X,

an the elevation to 0 X.an the elevation to 0 X.

Page 54: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 54/120

MATLAB orientation courseMATLAB orientation course

0ie$%points! Camera and 'ighting0ie$%points! Camera and 'ighting

>> pea7s#>> pea7s#

>> vie* (!Z0,0)>> vie* (!Z0,0)

>> vie*(9H0,90)>> vie*(9H0,90)

>> vie*(0,L0)>> vie*(0,L0)

Qie*pointQie*point (cont.)(cont.)

Page 55: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 55/120

MATLAB orientation courseMATLAB orientation course

0ie$%points! Camera and 'ighting0ie$%points! Camera and 'ighting

aeraaera$n orer to aniate caera otion, certain technical terinologies pertaining$n orer to aniate caera otion, certain technical terinologies pertaining

the sae nee to /e unerstoo, at least %unaentally. Jere are soe o%the sae nee to /e unerstoo, at least %unaentally. Jere are soe o%

those use%ul terinologies:those use%ul terinologies:

;olly;olly:: -ove %or*ar, along the line o% sight o% the caera (to*ars the o/Nect-ove %or*ar, along the line o% sight o% the caera (to*ars the o/Nect

o% interest).o% interest).

Trac7Trac7:: -ove horiontally, perpenicular to the line o% sight o% the caera. -ore-ove horiontally, perpenicular to the line o% sight o% the caera. -oregenerally, ove in a horiontal plane.generally, ove in a horiontal plane.

ranerane:: Saise the caera vertically.Saise the caera vertically.

Tilt (Ban7)Tilt (Ban7):: Sotate a/out the horiontal axis perpenicular to the line o% sight o%Sotate a/out the horiontal axis perpenicular to the line o% sight o%

the caera.the caera.

Pan ('a*)Pan ('a*):: Sotate a/out the vertical axis o% the caera (a%ter tilt).Sotate a/out the vertical axis o% the caera (a%ter tilt).

Ooo (in, out)Ooo (in, out):: hange the angular %iel o% vie* o% the caera.hange the angular %iel o% vie* o% the caera.

FocusFocus:: hange the %ocal epth, i.e. the istance at *hich o/Nects are in %ocus.hange the %ocal epth, i.e. the istance at *hich o/Nects are in %ocus.

;epth o% Fiel;epth o% Fiel::  hanging the aperture sie has the e%%ect o% changing thehanging the aperture sie has the e%%ect o% changing the

epth o% %iel, i.e., the range o% epths over *hich o/Nects can /e consiere toepth o% %iel, i.e., the range o% epths over *hich o/Nects can /e consiere to

/e in %ocus./e in %ocus.

Page 56: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 56/120

MATLAB orientation courseMATLAB orientation course

0ie$%points! Camera and 'ighting0ie$%points! Camera and 'ighting

aeraaeraThe aera Tool/ar ena/les you to per%or a nu/er o% vie*ingThe aera Tool/ar ena/les you to per%or a nu/er o% vie*ing

operations interactively. To use the aera Tool/ar: ;isplay the tool/aroperations interactively. To use the aera Tool/ar: ;isplay the tool/ar

/y selecting aera Tool/ar %ro the %igure *ino*6s Qie* enu./y selecting aera Tool/ar %ro the %igure *ino*6s Qie* enu.

se aerase aeratool/ar to per%ortool/ar to per%or

vie*ing operationvie*ing operation

interactivelyinteractively

The %unctionThe %unction cameramenucameramenu  also ena/les interactivealso ena/les interactive

anipulation o% a scene6s caera an light /y ragging theanipulation o% a scene6s caera an light /y ragging the

ouse on the %igure *ino*ouse on the %igure *ino*

Page 57: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 57/120

MATLAB orientation courseMATLAB orientation course

0ie$%points! Camera and 'ighting0ie$%points! Camera and 'ighting

1ighting1ightingThe %unctionThe %unction lightlight creates a *hite light source.creates a *hite light source.

FunctionFunction lightinglighting controls the lighting o% the o/Nects.controls the lighting o% the o/Nects.

The user ay chooseThe user ay choose

%ro %our i%%erent lighting%ro %our i%%erent lightingoels:oels: FlatFlat 4ourau4ourau PhongPhong MoneMone

Page 58: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 58/120

MATLAB orientation courseMATLAB orientation course

0ie$%points! Camera and 'ighting0ie$%points! Camera and 'ighting

alightalight

FunctionFunction calightcalight create or set position o% a light.create or set position o% a light.

 alight healight 9alight healight 9 creates a light in the current axes atcreates a light in the current axes at

the caera position o% the current axes.the caera position o% the current axes.

alight right 9alight right 9 creates a light right an up %ro caera.creates a light right an up %ro caera.

 alight le%t 9alight le%t 9 creates a light le%t an up %ro caera.creates a light le%t an up %ro caera.

 alight 9alight 9 is sae as calight rightis sae as calight right

  alight(5, 3l) 9alight(5, 3l) 9  creates a light at aiuthal ancreates a light at aiuthal an

elevation angle o% 5 an 3l respectively %ro caera.elevation angle o% 5 an 3l respectively %ro caera.

Page 59: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 59/120

Page 60: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 60/120

MATLAB orientation courseMATLAB orientation course

;isplay the slice9plot;isplay the slice9plot+et the axis aspect ratio+et the axis aspect ratioalculate the oain iensionsalculate the oain iensions+et the axis properties an the %acecolor an the egecolor+et the axis properties an the %acecolor an the egecolor

0olume 0isuali*ation echni1ues0olume 0isuali*ation echni1ues

>> loa *in>> loa *in

>> xin = in(x(:))#>> xin = in(x(:))#

>> xax = ax(x(:))#>> xax = ax(x(:))#

>> yin = in(y(:))#>> yin = in(y(:))#>> yax = ax(y(:))#>> yax = ax(y(:))#

>> in = in((:))#>> in = in((:))#

>> ax = ax((:))#>> ax = ax((:))#

>> aspect([,,!")#>> aspect([,,!")#

>> sliceVx = linspace(xin,xax,)#>> sliceVx = linspace(xin,xax,)#

>> hsur%aces = slice(x,y,,*inVspee,sliceVx,yax,in)#>> hsur%aces = slice(x,y,,*inVspee,sliceVx,yax,in)#

>> axis tight# vie*(0,0)# axis o%%>> axis tight# vie*(0,0)# axis o%%

>> set(hsur%aces,6Faceolor6,6interp6,63geolor6,6none6)>> set(hsur%aces,6Faceolor6,6interp6,63geolor6,6none6)

1oas the *in ata1oas the *in ata

slice(x,y,,v,sx,sy,s)  ra*s slices o% array v along thex,y, irections at the points in the vectors +x,+y,+.

Page 61: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 61/120

MATLAB orientation courseMATLAB orientation course

+treatu/e (x, y, , u, v, *, startx, starty, start)+treatu/e (x, y, , u, v, *, startx, starty, start)

ra*s strea tu/es %ro vector ata u, v, *.ra*s strea tu/es %ro vector ata u, v, *.  x, y, e%ine the coorinates %or the vectorx, y, e%ine the coorinates %or the vector

%iel.%iel. u, v, * e%ine the vector %iel.u, v, * e%ine the vector %iel.  startx, starty, an start e%ine the startingstartx, starty, an start e%ine the starting

positions o% the strealines at the center o% thepositions o% the strealines at the center o% the

tu/es. The *ith o% the tu/es is proportional totu/es. The *ith o% the tu/es is proportional to

the noralie ivergence o% the vector %iel.the noralie ivergence o% the vector %iel.

Mote:Mote:  These arrays ust /e the sae sie,These arrays ust /e the sae sie,

onotonic, an 9; plai.onotonic, an 9; plai.

FunctionFunction streatu/estreatu/e

0olume 0isuali*ation echni1ues0olume 0isuali*ation echni1ues

Page 62: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 62/120

MATLAB orientation courseMATLAB orientation course

0olume 0isuali*ation echni1ues0olume 0isuali*ation echni1ues

>> loa *in>> loa *in

>> [sx sy s" = eshgri(Z0, [0 0 0", [G !0")#>> [sx sy s" = eshgri(Z0, [0 0 0", [G !0")#>> aspect([!,!,!")#>> aspect([!,!,!")#

>> h=streatu/e(x,y,,u,v,*,sx,sy,s)#>> h=streatu/e(x,y,,u,v,*,sx,sy,s)#

>> set(h,6%acecolor6,6cyan6,6egecolor6,6none6)#>> set(h,6%acecolor6,6cyan6,6egecolor6,6none6)#

>> axis tight# vie*(0,0)# /ox on>> axis tight# vie*(0,0)# /ox on

>> caproN perspective# caoo(!.G)>> caproN perspective# caoo(!.G)

>> calight right# lighting phong>> calight right# lighting phong

1oa the *in ata1oa the *in ataoputes the starting positions o% the strea9tu/e centerlinesoputes the starting positions o% the strea9tu/e centerlinesalculate the axis aspect ratiosalculate the axis aspect ratiosPlot the strea9tu/ePlot the strea9tu/e+et the %acecolor an the egecolor+et the %acecolor an the egecolor+et the axis properties an the vie*ing angle+et the axis properties an the vie*ing angle+et the calight properties+et the calight properties

Page 63: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 63/120

MATLAB orientation courseMATLAB orientation course

0olume 0isuali*ation echni1ues0olume 0isuali*ation echni1ues

coneplot(x,y,,u,v,*,cx,cy,c) plots velocity vectorsconeplot(x,y,,u,v,*,cx,cy,c) plots velocity vectors

as cones pointing in the irection o% the velocityas cones pointing in the irection o% the velocity

vector an having a length proportional to thevector an having a length proportional to the

agnitue o% the velocity vector.agnitue o% the velocity vector.

x, y, e%ine the coorinates %or the vectorx, y, e%ine the coorinates %or the vector

%iel.%iel.

u, v, * e%ine the vector %iel.u, v, * e%ine the vector %iel.

cx, cy, c e%ine the location o% the cones incx, cy, c e%ine the location o% the cones in

vector %iel.vector %iel.

Mote:Mote:  These arrays ust /e the sae sie,These arrays ust /e the sae sie,

onotonic, an 9; plai.onotonic, an 9; plai.

FunctionFunction coneplotconeplot

Page 64: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 64/120

MATLAB orientation courseMATLAB orientation course

0olume 0isuali*ation echni1ues0olume 0isuali*ation echni1ues

>> loa *in>> loa *in>> xin = in(x(:))#>> xin = in(x(:))#

>> xax = ax(x(:))#>> xax = ax(x(:))#

>> yin = in(y(:))#>> yin = in(y(:))#

>> yax = ax(y(:))#>> yax = ax(y(:))#

>> in = in((:))#>> in = in((:))#

>> ax = ax((:))#>> ax = ax((:))#

>> aspect([,,!")>> aspect([,,!")

>> xrange = linspace(xin,xax,Z)#>> xrange = linspace(xin,xax,Z)#

>> yrange = linspace(yin,yax,Z)#>> yrange = linspace(yin,yax,Z)#

>> range = linspace(in,ax,Z)#>> range = linspace(in,ax,Z)#

>> [cx cy c" = eshgri(xrange,yrange,range)#>> [cx cy c" = eshgri(xrange,yrange,range)#

>> hcones = coneplot(x,y,,u,v,*,cx,cy,c,G)#>> hcones = coneplot(x,y,,u,v,*,cx,cy,c,G)#

>> set(hcones,6Faceolor6,6re6,63geolor6,6none6)>> set(hcones,6Faceolor6,6re6,63geolor6,6none6)>> axis tight# vie*(0,0)# axis o%%>> axis tight# vie*(0,0)# axis o%%

1oas the *in ata1oas the *in ata+et the axis liits+et the axis liits+et the axis aspect ratio+et the axis aspect ratioreate cx, cy an c to speci%y location o% cones in vector %ielreate cx, cy an c to speci%y location o% cones in vector %iel;isplays the coneplot *ith the cones stretche G ties;isplays the coneplot *ith the cones stretche G ties+et %acecolor an egecolor o% the cones+et %acecolor an egecolor o% the cones+et axis properties an vie*ing angle+et axis properties an vie*ing angle

Page 65: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 65/120

MATLAB orientation courseMATLAB orientation course

0olume 0isuali*ation echni1ues0olume 0isuali*ation echni1ues>> hol on>> hol on

>> *inVspee = srt(u. v. *.)#>> *inVspee = srt(u. v. *.)#

>> hsur%aces = slice(x,y,,*inVspee,[xin,xax",yax,in)#>> hsur%aces = slice(x,y,,*inVspee,[xin,xax",yax,in)#

>> set(hsur%aces,6Faceolor6,6interp6,63geolor6,6none6)>> set(hsur%aces,6Faceolor6,6interp6,63geolor6,6none6)

>> hol o%%>> hol o%%

>> caproN perspective# caoo(!.G)>> caproN perspective# caoo(!.G)

>> calight right# lighting phong>> calight right# lighting phong

>> set(hsur%aces,65/ient+trength6,.H)>> set(hsur%aces,65/ient+trength6,.H)

>> set(hcones,6;i%%use+trength6,.Z)>> set(hcones,6;i%%use+trength6,.Z)

Jols the current plotJols the current plotalculate the *in speealculate the *in spee;isplays the voluetric slice plot;isplays the voluetric slice plot+et the sliceplot sur%ace properties+et the sliceplot sur%ace properties+et the calight properties+et the calight properties

Page 66: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 66/120

MATLAB orientation courseMATLAB orientation course

Printing and Saving &raphicsPrinting and Saving &raphics

an save %igure to a .%ig %ile %ro the 4$an save %igure to a .%ig %ile %ro the 4$

2pening the %ile (%ro 4$) *ill recreate the2pening the %ile (%ro 4$) *ill recreate the

%igure%igure

The %igure *ill contain sae o/Nects as /e%oreThe %igure *ill contain sae o/Nects as /e%ore

can a to the %igure or eit o/Nectscan a to the %igure or eit o/Nects

Print through 4$ or coan linePrint through 4$ or coan line

print /y itsel% *ill sen gc% to e%ault printerprint /y itsel% *ill sen gc% to e%ault printer

Page 67: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 67/120

MATLAB orientation courseMATLAB orientation course

an save %igures to several stanar graphicsan save %igures to several stanar graphics%orats using print%orats using print

print 9Npeg %nae.Npgprint 9Npeg %nae.Npg *ill save gc% to a WP34 *ill save gc% to a WP34%ile%ile

WP34 (Woint Photographic 3xperts 4roup) %ile isWP34 (Woint Photographic 3xperts 4roup) %ile is

a stanar raster %ilea stanar raster %ilea raster %ile is a atrix o% pixelsa raster %ile is a atrix o% pixels

This eans that they have a %ixe resolutionThis eans that they have a %ixe resolution

U i% you /lo* up a WP34, the uality *ill eclinei% you /lo* up a WP34, the uality *ill ecline(you *ill /egin to see the pixels(you *ill /egin to see the pixels

U can control the resolution usingcan control the resolution using 9r\pixelsAinch>9r\pixelsAinch>

WP34s are extreely porta/le (can vie* the inWP34s are extreely porta/le (can vie* the ina *e/ /ro*ser) an copacta *e/ /ro*ser) an copact

4oo i% your %igure is very coplex (lots o% ;4oo i% your %igure is very coplex (lots o% ;o/Nects an color)o/Nects an color)

E2porting graphicsE2porting graphics

Page 68: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 68/120

MATLAB orientation courseMATLAB orientation course

print 9epsc %nae.epsprint 9epsc %nae.eps *ill save gc% to an 3P+ *ill save gc% to an 3P+%ile%ile

3P+ (encapsulate post script) is stanar %orat3P+ (encapsulate post script) is stanar %orat

%or saving vector graphics%or saving vector graphics

Qector graphics are ae up o% atheaticalQector graphics are ae up o% atheatical

o/Nects99lines, Beier curves, polygons, text.o/Nects99lines, Beier curves, polygons, text.The o/Nects have properties such as line *eights,The o/Nects have properties such as line *eights,

%onts, ] colors%onts, ] colors

Because the o/Nects are representeBecause the o/Nects are represente

atheatically, 3P+ %iles can /e scale *ithoutatheatically, 3P+ %iles can /e scale *ithout

loosing resolutionloosing resolution

They are less porta/le than WP34s (nee specialThey are less porta/le than WP34s (nee special

so%t*are li7e $llustrator, or ghostscript)so%t*are li7e $llustrator, or ghostscript)

Jo*ever, you can eit the %ile easilyJo*ever, you can eit the %ile easily

E2porting &raphicsE2porting &raphics

Page 69: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 69/120

MATLAB orientation courseMATLAB orientation course

reatingreating

Animations usingAnimations usingMATLABMATLAB

Page 70: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 70/120

MATLAB orientation courseMATLAB orientation course

Animations in MA'A)Animations in MA'A)

Facilities %or aniation in -5T15BFacilities %or aniation in -5T15B

+ave a nu/er o% i%%erent pictures an+ave a nu/er o% i%%erent pictures an

then play the /ac7 as a ovie.then play the /ac7 as a ovie.

3rase -oe -etho3rase -oe -etho

reating -oviesreating -ovies

ontinually erase an then rera* theontinually erase an then rera* the

o/Nects on the screen, a7ing increentalo/Nects on the screen, a7ing increental

changes *ith each rera*.changes *ith each rera*.

Page 71: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 71/120

Page 72: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 72/120

MATLAB orientation courseMATLAB orientation course

Animations in MA'A)Animations in MA'A)

-ovies-ovies

$% you have a seuence o% plots that you$% you have a seuence o% plots that you

 *oul li7e to aniate, the ovie9a7ing *oul li7e to aniate, the ovie9a7ing

%unctions in -5T15B can /e invo7e. This%unctions in -5T15B can /e invo7e. This

/asically involves t*o steps:/asically involves t*o steps:

  sese get%raeget%rae to generate each ovie %rae.to generate each ovie %rae.

sese ovieovie  to run the ovie a speci%ieto run the ovie a speci%ie

nu/er o% ties at the speci%ie rate.nu/er o% ties at the speci%ie rate.

Page 73: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 73/120

Page 74: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 74/120

MATLAB orientation courseMATLAB orientation course

Animations in MA'A)Animations in MA'A)

5 saple -5T15B -ovie5 saple -5T15B -ovie

1et us try to a7e a ovie that sho*s the path o% a proNectile (/all)1et us try to a7e a ovie that sho*s the path o% a proNectile (/all)

 *ith euations o% otion as: *ith euations o% otion as:

x =x = (u cos^)(u cos^)t# y =t# y = (u sin^) t 9 _ g t(u sin^) t 9 _ g t 

>> u=0.0#>> u=0.0#>> theta=GIpiA!Z0#>> theta=GIpiA!Z0#

>> g=L.Z!#>> g=L.Z!#

>> xVrange=uIsin(Itheta)Ag#>> xVrange=uIsin(Itheta)Ag#

>> axVht=0.GIuI(sin(theta))Ag#>> axVht=0.GIuI(sin(theta))Ag#

>> TV%light=IuIsin(theta)Ag#>> TV%light=IuIsin(theta)Ag#

>> axis([0 xVrange 0 axVht")>> axis([0 xVrange 0 axVht")>> axis eual>> axis eual

+peci%y the initial spee o% the proNectile+peci%y the initial spee o% the proNectile+peci%y the angle o% proNection (G egrees)+peci%y the angle o% proNection (G egrees)Joriontal rangeJoriontal range-axiu Jeight-axiu JeightTie o% %lightTie o% %light+et the axis properties+et the axis properties

Page 75: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 75/120

Page 76: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 76/120

MATLAB orientation courseMATLAB orientation course

Some sample animations in MA'A)Some sample animations in MA'A)

Animation o# a stic+ #igureAnimation o# a stic+ #igure Pendulum AnimationPendulum Animation

Page 77: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 77/120

Page 78: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 78/120

MATLAB orientation courseMATLAB orientation course

&raphical 3ser Interface&raphical 3ser Interface

5 graphical user inter%ace (4$) is a user5 graphical user inter%ace (4$) is a userinter%ace /uilt *ith graphical o/Nects, such asinter%ace /uilt *ith graphical o/Nects, such as

/uttons, text %iels, sliers, an enus/uttons, text %iels, sliers, an enus

5pplications that provie 4$s are generally5pplications that provie 4$s are generally

easier to learn an use since the personeasier to learn an use since the personusing the application oes not nee to 7no*using the application oes not nee to 7no*

 *hat coans are availa/le or ho* they *hat coans are availa/le or ho* they

 *or7 *or7

The action that results %ro a particular userThe action that results %ro a particular useraction can /e ae clear /y the esign o% theaction can /e ae clear /y the esign o% the

inter%aceinter%ace

Page 79: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 79/120

MATLAB orientation courseMATLAB orientation course

1aying out the coponents1aying out the coponents

Prograing the to o speci%ic things inPrograing the to o speci%ic things in

response to user actionsresponse to user actions

+aving an launching the 4$+aving an launching the 4$

-o$ to create &3Is $ith MA'A) 4-o$ to create &3Is $ith MA'A) 4

Page 80: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 80/120

MATLAB orientation courseMATLAB orientation course

Getting tartedGetting tarted

+elect C+ho* 4$+elect C+ho* 4$

1ayout ToolD %ro1ayout ToolD %ro

CFileD enu *ithinCFileD enu *ithin

-5T15B-5T15B

Page 81: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 81/120

MATLAB orientation courseMATLAB orientation course

Guide ontrol PanelGuide ontrol Panel

Press C5 FigureDPress C5 FigureDto get starteto get starte

Page 82: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 82/120

MATLAB orientation courseMATLAB orientation course

The Process o# Implementing a GUIThe Process o# Implementing a GUIIn"ol"es T&o Basic Tas+s)In"ol"es T&o Basic Tas+s)

1aying out the 4$ coponents1aying out the 4$ coponents

-5T15B ipleents 4$s as %igure *ino*s-5T15B ipleents 4$s as %igure *ino*scontaining various styles o% uicontrol (sercontaining various styles o% uicontrol (ser

$nter%ace) o/Nects$nter%ace) o/Nects

Prograing the 4$ coponentsPrograing the 4$ coponents

-ust progra each o/Nect to per%or the-ust progra each o/Nect to per%or theintene action *hen activate /y the user o%intene action *hen activate /y the user o%

the 4$the 4$

Implementing a &3IImplementing a &3I

Page 83: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 83/120

Page 84: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 84/120

MATLAB orientation courseMATLAB orientation course

CallbacksCallbacks

Soutine that executes *henever you activateSoutine that executes *henever you activate

the uicontrol o/Nectthe uicontrol o/Nect

;e%ine this routine as a string that is a vali;e%ine this routine as a string that is a vali-5T15B expression or the nae o% an -9-5T15B expression or the nae o% an -9

%ile%ile

The expression executes in the -5T15BThe expression executes in the -5T15B

 *or7space. *or7space.

Page 85: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 85/120

MATLAB orientation courseMATLAB orientation course

uicontrol obectsuicontrol obects

` Push ButtonsPush Buttons

` Toggle ButtonsToggle Buttons

` hec7 Boxeshec7 Boxes

` Saio ButtonsSaio Buttons

` 3it Text3it Text

` +tatic Text+tatic Text

` +liers+liers

` FraesFraes

` 1ist Boxes1ist Boxes

` Popup -enusPopup -enus

Page 86: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 86/120

MATLAB orientation courseMATLAB orientation course

$ush %uttons$ush %uttons&adio %uttons&adio %uttons

'rames'rames

heckboxheckbox   liderlider

dit textdit text

static textstatic textxesxes

uicontrol obectsuicontrol obects

Page 87: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 87/120

MATLAB orientation courseMATLAB orientation course

Push )uttonsPush )uttons

Push /uttons generate an action *hen pressePush /uttons generate an action *hen presse

(e.g., an 2 /utton ay close a ialog /ox an(e.g., an 2 /utton ay close a ialog /ox an

apply settings)apply settings)

hen you clic7 o*n on a push /utton, ithen you clic7 o*n on a push /utton, it

appears epresse# *hen you release theappears epresse# *hen you release the

ouse, the /utton6s appearance returns to itsouse, the /utton6s appearance returns to its

non9epresse state# an its call/ac7 executesnon9epresse state# an its call/ac7 executes

on the /utton up eventon the /utton up event

Page 88: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 88/120

MATLAB orientation courseMATLAB orientation course

oggle )uttonsoggle )uttons

Toggle /uttons generate an action aninicate a /inary state (e.g., on or o%%)

The call/ac7 routine nees to uery the toggle

/utton to eterine *hat state it is in

'ou can o this *ith a stateent that uses the

current call/ac7 o/Nect6s hanle (gc/o)

>> get(gc/o,6Qalue6)

-5T15B sets the Qalue property to ! *henepresse an 0 *hen not epresse

Page 89: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 89/120

MATLAB orientation courseMATLAB orientation course

Check )o2esCheck )o2es

4enerate an action *hen clic7e an4enerate an action *hen clic7e aninicate their state as chec7e or notinicate their state as chec7e or not

chec7echec7e

se%ul *hen proviing the user *ith ase%ul *hen proviing the user *ith a

nu/er o% inepenent choices that set anu/er o% inepenent choices that set aoeoe

The Qalue property inicates the state o% theThe Qalue property inicates the state o% the

chec7 /ox /y ta7ing on the value ! or 0chec7 /ox /y ta7ing on the value ! or 0

Qalue = !, /ox is chec7e.

Qalue = 0, /ox is not chec7e. 

Page 90: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 90/120

MATLAB orientation courseMATLAB orientation course

7adio )uttons7adio )uttons

+iilar to chec7 /oxes, /ut are intene to+iilar to chec7 /oxes, /ut are intene to

/e utually exclusive *ithin a group o%/e utually exclusive *ithin a group o%

relate raio /uttons (i.e., only one /utton isrelate raio /uttons (i.e., only one /utton is

in a selecte state at any given tie)in a selecte state at any given tie)

To a7e raio /uttons utually exclusiveTo a7e raio /uttons utually exclusive

 *ithin a group, the call/ac7 %or each raio *ithin a group, the call/ac7 %or each raio

/utton ust set the Qalue property to 0 on all/utton ust set the Qalue property to 0 on all

other raio /uttons in the groupother raio /uttons in the group

Page 91: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 91/120

MATLAB orientation courseMATLAB orientation course

Edit e2tEdit e2t

Fiels that ena/le users to enter or oi%yFiels that ena/le users to enter or oi%y

text stringstext strings

se eit text *hen you *ant text as inputse eit text *hen you *ant text as input

The +tring property contains the text entereThe +tring property contains the text entere

/y the user./y the user.

Page 92: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 92/120

MATLAB orientation courseMATLAB orientation course

Static e2tStatic e2t

;isplays lines o% text;isplays lines o% text

Typically use to la/el other controls,Typically use to la/el other controls,

provie irections to the user, or inicateprovie irections to the user, or inicatevalues associate *ith a sliervalues associate *ith a slier

sers cannot change static text interactivelysers cannot change static text interactively

an there is no *ay to invo7e the call/ac7an there is no *ay to invo7e the call/ac7routine associate *ith it.routine associate *ith it.

Page 93: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 93/120

MATLAB orientation courseMATLAB orientation course

SlidersSliders

5ccept nueric input *ithin a speci%ic range5ccept nueric input *ithin a speci%ic range

/y ena/ling the user to ove a sliing /ar/y ena/ling the user to ove a sliing /ar

The location o% the /ar inicates a nuericThe location o% the /ar inicates a nuericvaluevalue

an set urrent Qalue, Sange, an +tepan set urrent Qalue, Sange, an +tep

siesie

(our Properties that Control the(our Properties that Control the

Page 94: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 94/120

MATLAB orientation courseMATLAB orientation course

7ange and Step Si*e of the Slider7ange and Step Si*e of the Slider

QalueQalue  9 contains the current value o% the9 contains the current value o% the

slierslier

-ax-ax

 9 e%ines the axiu slier value.9 e%ines the axiu slier value.

-in-in 9 e%ines the iniu slier value.9 e%ines the iniu slier value.

+lier+tep+lier+tep  9 speci%ies the sie o% a slier9 speci%ies the sie o% a slier

step *ith respect to the range.step *ith respect to the range.

lid l

Page 95: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 95/120

MATLAB orientation courseMATLAB orientation course

Sliders %Sliders % 0alue0alue PropertyProperty

ontains the nueric value o% the slierontains the nueric value o% the slier

an set this property to speci%y an initialan set this property to speci%y an initial

conition an uery it in the slier6s call/ac7conition an uery it in the slier6s call/ac7to o/tain the value set /y the userto o/tain the value set /y the user

For exaple, your call/ac7 coul contain theFor exaple, your call/ac7 coul contain the

stateent:stateent:

>> slierVvalue = get(hanles.slier!,6Qalue6)#>> slierVvalue = get(hanles.slier!,6Qalue6)#

lidSlid d iM d Mi iP i

Page 96: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 96/120

MATLAB orientation courseMATLAB orientation course

Sliders %Sliders % Ma2 and MinMa2 and Min PropertiesProperties

The -ax an -in properties speci%y theThe -ax an -in properties speci%y the

slier6s range (-ax 9 -in)slier6s range (-ax 9 -in)

Page 97: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 97/120

MATLAB orientation courseMATLAB orientation course

Sliders %Sliders % SliderStepSliderStep PropertyProperty

ontrols the aount the slier Qalueontrols the aount the slier Qalue

property changes *hen you clic7 the ouseproperty changes *hen you clic7 the ouse

on the arro* /utton or on the slier troughon the arro* /utton or on the slier trough

+peci%y +lier+tep as a t*o9eleent vector+peci%y +lier+tep as a t*o9eleent vector

The e%ault, [0.0! 0.!0", provies a ! percentThe e%ault, [0.0! 0.!0", provies a ! percent

change %or clic7s on an arro* an a !0change %or clic7s on an arro* an a !0

percent change %or clic7s in the troughpercent change %or clic7s in the trough

The actual step sie is a %unction o% the slierThe actual step sie is a %unction o% the slierstep an the slier rangestep an the slier range

(

Page 98: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 98/120

MATLAB orientation courseMATLAB orientation course

(rames(rames

Boxes that enclose regions o% a %igureBoxes that enclose regions o% a %igure

 *ino* *ino*

an a7e a user inter%ace easier toan a7e a user inter%ace easier to

unerstan /y visually grouping relateunerstan /y visually grouping relate

controlscontrols

Jave no call/ac7 routines associate *ithJave no call/ac7 routines associate *ith

the an only uicontrols can appear *ithinthe an only uicontrols can appear *ithin

%raes (axes cannot)%raes (axes cannot)

'i t )'i t )

Page 99: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 99/120

MATLAB orientation courseMATLAB orientation course

'ist )o2es'ist )o2es

;isplay a list o% ites (e%ine using the;isplay a list o% ites (e%ine using the

+tring property) an ena/le users to select+tring property) an ena/le users to select

one or ore itesone or ore ites

By e%ault, the %irst ite in the list isBy e%ault, the %irst ite in the list is

highlighte *hen the list /ox is %irsthighlighte *hen the list /ox is %irst

isplayeisplaye

$% you o not *ant any ite highlighte, then$% you o not *ant any ite highlighte, then

set the Qalue property to epty, [ "set the Qalue property to epty, [ "

'i t )'i t ) 5 d65 /d6

Page 100: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 100/120

MATLAB orientation courseMATLAB orientation course

'ist )o2es'ist )o2es 5cont/d65cont/d6

The values o% the -in an -ax propertiesThe values o% the -in an -ax properties

eterine *hether users can a7e single oreterine *hether users can a7e single or

ultiple selections:ultiple selections:

$% -ax 9 -in > !, then list /oxes allo* ultiple$% -ax 9 -in > !, then list /oxes allo* ultiple

ite selectionite selection

$% -ax 9 -in \= !, then list /oxes o not allo*$% -ax 9 -in \= !, then list /oxes o not allo*

ultiple ite selectionultiple ite selection

ingle or Multiple electionsingle or Multiple elections

i l'i ) E l

Page 101: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 101/120

MATLAB orientation courseMATLAB orientation course

'ist )o2 E2ample'ist )o2 E2ample

P MP M

Page 102: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 102/120

MATLAB orientation courseMATLAB orientation course

Popup MenusPopup Menus

2pen to isplay a list o% choices (e%ine2pen to isplay a list o% choices (e%ineusing the +tring property) *hen users pressusing the +tring property) *hen users press

the arro*the arro*

hen not open, a popup enu isplays thehen not open, a popup enu isplays the

current choice, *hich is eterine /y thecurrent choice, *hich is eterine /y the

inex containe in the Qalue propertyinex containe in the Qalue property

The %irst ite in the list has an inex o% !The %irst ite in the list has an inex o% !

'ou can uery the Qalue property in the'ou can uery the Qalue property in the

call/ac7 routine to eterine *hich choicecall/ac7 routine to eterine *hich choice

the user aethe user ae

an /e use in place o% Saio Buttonsan /e use in place o% Saio Buttons

Page 103: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 103/120

&3IDE&3IDE

Page 104: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 104/120

MATLAB orientation courseMATLAB orientation course

5 Primarily a Set of 'ayout ools 65 Primarily a Set of 'ayout ools 6

ontrol Panelontrol Panel  9 a an arrange o/Nects in9 a an arrange o/Nects inthe %igure *ino*the %igure *ino*

5lignent Tool5lignent Tool 9 align o/Nects9 align o/Nects

Property 3itorProperty 3itor  9 inspect an set property9 inspect an set propertyvaluesvalues

2/Nect Bro*ser2/Nect Bro*ser  9 o/serve a hierarchical list9 o/serve a hierarchical list

o% the Janle 4raphics o/Nectso% the Janle 4raphics o/Nects

-enu 3itor-enu 3itor  9 create *ino* enus an9 create *ino* enus an

context enuscontext enus

C l P lC t l P l

Page 105: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 105/120

MATLAB orientation courseMATLAB orientation course

Control PanelControl Panel

3na/les you to select 4$ coponents %ro3na/les you to select 4$ coponents %ro

a palette an arrange the in a %igurea palette an arrange the in a %igure

 *ino* *ino*

The coponent palette contains the 4$The coponent palette contains the 4$

coponents (uicontrol o/Nects) that arecoponents (uicontrol o/Nects) that are

availa/le %or you to use in your user inter%aceavaila/le %or you to use in your user inter%ace

Control PanelControl Panel 5 t/d65 t/d6

Page 106: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 106/120

MATLAB orientation courseMATLAB orientation course

Control PanelControl Panel 5cont/d65cont/d6

Alig t lAlignment ool

Page 107: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 107/120

MATLAB orientation courseMATLAB orientation course

Alignment oolAlignment ool

3na/les you to position o/Nects *ith respect3na/les you to position o/Nects *ith respect

to each other an to aNust the spacingto each other an to aNust the spacing

/et*een selecte o/Nects/et*een selecte o/Nects

The speci%ie alignent operations apply toThe speci%ie alignent operations apply to

all coponents that are selecte *hen youall coponents that are selecte *hen you

press the C5pplyD /uttonpress the C5pplyD /utton

Alig t lAlignment ool 5 /d65 t/d6

Page 108: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 108/120

MATLAB orientation courseMATLAB orientation course

Alignment oolAlignment ool 5cont/d65cont/d6

5lignent5lignent

2ptions2ptions

2/Nect Bro*ser2/Nect Bro*ser

(highlighte ones(highlighte ones

have /een selecte)have /een selecte)

Propert EditorProperty Editor

Page 109: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 109/120

MATLAB orientation courseMATLAB orientation course

Property EditorProperty Editor

3na/les you to set the properties o% the3na/les you to set the properties o% the

coponents in your layoutcoponents in your layout

Provies a list o% all setta/le properties anProvies a list o% all setta/le properties anisplays the current valueisplays the current value

Property EditorProperty Editor 5 t/d65 t/d6

Page 110: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 110/120

MATLAB orientation courseMATLAB orientation course

Property EditorProperty Editor 5cont/d65cont/d6

2/Nect Bro*ser2/Nect Bro*ser

(highlighte ones(highlighte ones

have /een selecte)have /een selecte)

Properties *ithProperties *ith

corresponingcorresponing

valuesvalues

Menu EditorMenu Editor

Page 111: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 111/120

MATLAB orientation courseMATLAB orientation course

Menu EditorMenu Editor

5llo*s enus on %igures to /e interactively5llo*s enus on %igures to /e interactively

oi%ieoi%ie

The 1a/el, Tag, an all/ac7 properties canThe 1a/el, Tag, an all/ac7 properties can/e oi%ie irectly on the tool/e oi%ie irectly on the tool

Menu EditorMenu Editor 5 t/d65cont/d6

Page 112: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 112/120

MATLAB orientation courseMATLAB orientation course

Menu EditorMenu Editor 5cont/d65cont/d6

(il (il

Page 113: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 113/120

MATLAB orientation courseMATLAB orientation course

$o (iles$o (iles

5 F$49%ile5 F$49%ile 5 -9%ile5 -9%ile

  5 F$49%ile contains a5 F$49%ile contains a

coplete escription o%coplete escription o%

the 4$ %igure an all o%the 4$ %igure an all o%

its chilren (uicontrolsits chilren (uicontrols

an axes), as *ell as thean axes), as *ell as the

values o% all o/Nectvalues o% all o/Nect

propertiesproperties

 5n -9%ile contains the5n -9%ile contains the

%unctions that launch%unctions that launch

an control the 4$ anan control the 4$ an

the call/ac7s, *hich arethe call/ac7s, *hich are

e%ine as su/9%unctionse%ine as su/9%unctions

(I& files(I& files

Page 114: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 114/120

MATLAB orientation courseMATLAB orientation course

(I&%files(I&%files

Binary %iles create as a result o% saving a

%igure

ontains a serialie %igure o/Nect

5 coplete escription o% the %igure o/Nect anall o% its chilren

5ll o% the o/Nects property values are set to

the values they *ere save *ith *hen the

%igure is recreate

M filM fil

Page 115: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 115/120

MATLAB orientation courseMATLAB orientation course

M%filesM%files

-5T15B generates the application -9%ile to-5T15B generates the application -9%ile to

provie a %rae*or7 %or the progra thatprovie a %rae*or7 %or the progra that

controls the 4$controls the 4$

5ll coe, incluing the call/ac7s, is containe5ll coe, incluing the call/ac7s, is containe

in the application -9%ilein the application -9%ile

3ach call/ac7 is ipleente as a su/9

%unction in the -9%ile

E2ample8E2ample8 'aunching a Dialog to Confirm'aunching a Dialog to Confirm

# i# i

Page 116: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 116/120

MATLAB orientation courseMATLAB orientation course

an #perationan #peration

$llustrates ho* to isplay a ialog *hen$llustrates ho* to isplay a ialog *hen

users attept to close a 4$users attept to close a 4$

The purpose o% the ialog is to %orce theThe purpose o% the ialog is to %orce theuser to con%ir that they really *ant touser to con%ir that they really *ant to

procee *ith the close operationprocee *ith the close operation

#bective of Dialog )o2#bective of Dialog )o2

Page 117: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 117/120

MATLAB orientation courseMATLAB orientation course

#bective of Dialog )o2#bective of Dialog )o2

ant it to /e launche /y the application6sant it to /e launche /y the application6sCloseD /uttonCloseD /utton

5s7 the user to con%ir the close operation5s7 the user to con%ir the close operation

(i.e., respon yes or no)(i.e., respon yes or no) 

Bloc7 -5T15B execution until the userBloc7 -5T15B execution until the user

responsrespons

Janle the case *here the user closes theJanle the case *here the user closes theialog %ro the *ino* anager close /oxialog %ro the *ino* anager close /ox

 *ithout responing *ithout responing

'aunching Dialog'aunching Dialog

Page 118: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 118/120

MATLAB orientation courseMATLAB orientation course

'aunching Dialog'aunching Dialog

The CloseD /utton6s call/ac7 nees to launchThe CloseD /utton6s call/ac7 nees to launch

a ialog that as7s %or con%iration o% thea ialog that as7s %or con%iration o% the

ipening close operationipening close operation

This call/ac7 ust then *ait %or a ialog toThis call/ac7 ust then *ait %or a ialog toreturn a valuereturn a value

To accoplish this, the ialog6s application -9

%ile assigns an output arguent an the CloseD

/utton6s call/ac7 *aits %or it to /e returne

Illustration of a Dialog )o2Illustration of a Dialog )o2

over a &3I (igureover a &3I (igure

Page 119: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 119/120

MATLAB orientation courseMATLAB orientation course

over a &3I (igureover a &3I (igure

Page 120: Matlab_GUI and Graphics Programming FINAL

8/11/2019 Matlab_GUI and Graphics Programming FINAL

http://slidepdf.com/reader/full/matlabgui-and-graphics-programming-final 120/120

Than+ 6ouThan+ 6ou