Lecture+05+Presentation

Lecture+05+Presentation - 14:440: 127 Introduction to...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
14:440: 127 Introduction to Computers for Engineers Lecture 5 Lecturer: Brenda Cortez Recitation Instructors: Yun, Bo, Karthik, Muhammad
Background image of page 1

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

View Full DocumentRight Arrow Icon
Rutgers School of Engineering 14:440:127 General Announcements HW01 PROJ01 EXAM01 - LAST DAY TODAY No ofFce Hours on TUESDAYS o/w Open Door Policy active HW02 Assigned this Wednesday Missing something? I have a wallet, cell phone, and RUIDs in my ofFce apps.rutgers.edu - try it out again and answer bi-weekly polls on Sakai 2
Background image of page 2
Rutgers School of Engineering 14:440:127 Topic for today: Plotting 2D, 3D, Meshgrid, Log plots Graphical Input Interpolation Regression Fitting Equation to Data 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
14:440:127 2D Plots What do you need? - X points - Y points >> xpoints = linspace(1,10,20); >> ypoints = rand (1,20)*10; Obviously size(x)==size(y) has to be true, so that you can have corresponding points. Now Plot! >> plot (xpoints, ypoints) 4 returns a vector of rand om numbers of size ( rows , cols ) from 0 to 1
Background image of page 4
14:440:127 >> xpoints2 = 1:5:50; >> ypoints2 = x .^ 3; >> plot (xpoints2, ypoints2) >> title ( ʻ X Cubed! ʼ ) >> xlabel ( ʻ X points ʼ ) >> ylabel ( ʻ Y points ʼ ) >> grid on 5 Only if you want to have a grid look, otherwise, the plot will be on a white background
Background image of page 5

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

View Full DocumentRight Arrow Icon
14:440:127 Multiple Figures Sometimes, you need to visualize data in different windows, but at the same time, so you must create the Fgure separately and THEN plot. fgure (1) plot (xpoints, ypoints) fgure (2) plot (xpoints2, ypoints2) 6 If you want to overwrite a plot, simply use the Fgure ʼ s number: fgure (1) plot (xpoints2, ypoints2)
Background image of page 6
14:440:127 Multiple graphs in ONE fgure - Method 1 >> x1 = 1:0.1:10; >> x2 = 1.5:0.1:10; >> y1 = 3*x1 .^ 2; >> y2 = 3.5*x2 .^ (1.5); >> plot ( x1 , y1 , x2 , y2 ) 7 But we need to distinguish between the two, so we can use legend to distinguish. legend ('frst line', 'second line')
Background image of page 7

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

View Full DocumentRight Arrow Icon
14:440:127 Multiple Graphs in ONE fgure - Method 2 >> x1 = 1:0.1:10; >> x2 = 1.5:0.1:10; >> y1 = 3*x1 .^ 2; >> y2 = 3.5*x2 .^ (1.5); >> plot (x1, y1) >> hold on >> plot (x2, y2) >> hold oFF 8 However, the legend command does not work too well.
Background image of page 8
14:440:127 Common Error Suppose you have your X and Y points and you do the following: plot (x) % OR plot (y) This will work, but it is wrong if you are trying to plot y against x. It works because: this plots x OR y against their indices Example: x=1:2:10; 9 1 3 5 7 9 the values in x 1 2 3 4 5 indices of the elements in x
Background image of page 9

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

View Full DocumentRight Arrow Icon
14:440:127 Subplots To create the fgure on which to plot using subplot you must frst defne the size oF this fgure, in other words, how many slots to plot on. Syntax: subplot ( rows , columns ) Examples: subplot ( 2 , 2 ) subplot ( 3 , 4 ) subplot ( 3 , 1 ) 10 loc=1 loc=2 loc=3 loc=4 loc=1 loc=2 loc=3 loc=4 loc=5 loc=6 loc=7 loc=8 loc=9 loc=10 loc=11 loc=12 loc=1 loc=2 loc=3
Background image of page 10
14:440:127 Subplots >> x = linspace(0,10,100); >> y1 = x; >> y2 = x.^2; >> y3 = x.^3; >> y4 = x.^4;
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 03/14/2011.

Page1 / 36

Lecture+05+Presentation - 14:440: 127 Introduction to...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online