Plot from “Data”
? MATLAB does not understand functions
????(??) = sin(2????)
? Strategies
- Generate the numeric values of a function over a specific range.
- Display the data “points” in a graphical way.
plot()
? plot(x,y) plots each vector pairs (x,y)
? plot(y) plots each vector pairs (x,y),where x=[1…n], n=length(y)
? Example:
??plot(cos(0:pi/20:2*pi));
hold on/off
? Use hold on to have both plots in one figure.

Plot Style
? plot(x,y,'str') plots each vector pairs (x,y) using the format defined in str (check linespec)

legend()
? Add legend to graph
??legend('L1',...)
? Position adjustment


title() and label()
? title()
? xlabel()
? ylabel()
? zlabel()


text() and annotation()
? Text with mathematical expression using LaTex


Exercise
? Plot ?? as a black line and ?? as a series of red circles for the range t = 1 to 2 in one figure
???? = and ?? = sin(2????)
? Label each axis, and add title and legend

Figure Adjustment
? Several properties:
? Font
? Font size
? Line width
? Axis limit
? Tick position
? Tick label
Graphical Objects
? A figure is composed of many objects

Figure Properties
屏幕截圖(82).png

Modifying Properties of An Object
? Strategy:
- Identify the “handle” of an object
- Fetch or modify the object’s properties
? For example, to change the limits of the x-axis:
- Find the handle of the x-axis
- Modify the limits
1. Identifying the Handle of An Object
? Upon creation:
??h = plot(x,y);

? Utility functions:

Fetching or Modifying Properties
? To fetch properties, use
??get( )
? To modify properties, use
??set( )
Getting Object Properties
? Getting properties of a graphical object: get( )
Setting Axes Limits
