22. Plotting Data - ENGR 101, Section 100, Fall 10...

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

View Full Document Right Arrow Icon
ENGR 101, Section 100, Fall 10 M. Wellman 1 Visualizing Data ENGR 101, Lecture 22: 1 Dec 10 Announcements Project 7 due tonight : Wed 1 Dec Project 8 out tonight, due Mon 13 Dec No extensions possible Dealing with MATLAB license contention
Background image of page 1

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

View Full DocumentRight Arrow Icon
ENGR 101, Section 100, Fall 10 M. Wellman 2 MATLAB Type Conversions Sometimes automatic ( coercion ): 'a' + 3 100 'a' + 'b' 195 90 + true 91 ~[40 0 -3] [0 1 0] (logicals) Can also use explicit conversion ( cast ) functions: logical([40 0]) [1 0] (logicals) char(98) b double('b') 98 Array Element Types In an array, all elements must be same type Element type determined on array initialization v = 1:5 a vector of numbers w = 'abcde' a vector of characters Assigning different types to elements will cause a conversion v(3) = 'x' v = [ 1 2 120 4 5 ] w(3) = 120 w = 'abxde' To assign an element to chosen type, initialize that way or perform explicit conversion v(numElts) = 'x'; v = ones(1,numElts); v = char(v); v = char('x' * ones(1,numElts));
Background image of page 2
ENGR 101, Section 100, Fall 10 M. Wellman 3 Plotting Data in MATLAB plot : general plotting function Many forms, depending on number and content of arguments Generates a new figure (e.g., for a graph) in the Figure window Opens new window if necessary Basic form: plot ( x , y ) x is a vector of x values y is a vector of y values x = 1:0.1:10; y = x .^ 2 – 10 * x + 15; plot(x, y); Plot draws corresponding (x,y) points on graph, connecting adjacent points in vectors by lines Adding Information to a Figure title( title_string ) Adds specified title to figure (or changes existing title) xlabel( label_string ) ylabel( label_string ) Adds specified axis label to figure (or changes existing label) grid : sets (or toggles) presence of grid lines title('A Parabola'); xlabel('x value'); ylabel('y value'); grid on;
Background image of page 3

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

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

Page1 / 14

22. Plotting Data - ENGR 101, Section 100, Fall 10...

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

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