MATLAB_Plotting

MATLAB_Plotting - Two Dimensional Plots Chapter 5 Topics...

This preview shows pages 1–9. Sign up to view the full content.

Topics Covered: 1. Plotting basic 2-D plots. The plot command. Plotting multiple graphs in the same plot. Formatting plots. Two Dimensional Plots / Chapter 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
MAKING X-Y PLOTS MATLAB has many functions and commands that can be used to create various types of plots. In our class we will only create two dimensional x – y plots.
8 10 12 14 16 18 20 22 24 0 200 400 600 800 1000 1200 DISTANCE (cm) INTENSITY (lux) Light Intensity as a Function of Distance Comparison between theory and experiment. Theory Experiment Plot title y axis label x axis label Text Tick-mark label EXAMPLE OF A 2-D PLOT Data symbol Legend Tick-mark

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
TWO-DIMENSIONAL plot() COMMAND where x is a vector (one dimensional array), and y is a vector. Both vectors must have the same number of elements. The plot command creates a single curve with the x values on the abscissa (horizontal axis) and the y values on the ordinate (vertical axis). The curve is made from segments of lines that connect the points that are defined by the x and y coordinates of the elements in the two vectors. The basic 2-D plot command is: plot(x,y)
If data is given, the information is entered as the elements of the vectors x and y . If the values of y are determined by a function from the values of x , than a vector x is created first, and then the values of y are calculated for each value of x . The spacing (difference) between the elements of x must be such that the plotted curve will show the details of the function. CREATING THE X AND Y VECTORS

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
PLOT OF GIVEN DATA Given data: >> x=[1 2 3 5 7 7.5 8 10]; >> y=[2 6.5 7 7 5.5 4 6 8]; >> plot(x,y) A plot can be created by the commands shown below. This can be done in the Command Window, or by writing and then running a script file. Once the plot command is executed, the Figure Window opens with the following plot. x y 1 2 3 5 7 7.5 8 6.5 7 7 5.5 4 6 8 10 2
PLOT OF GIVEN DATA

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
plot() COMMAND Line specifiers can be added in the plot command to: Specify the style of the line. Specify the color of the line. Specify the type of the markers (if markers are desired). plot(x,y,’line specifiers’)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 30

MATLAB_Plotting - Two Dimensional Plots Chapter 5 Topics...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online