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

Info icon This 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
Image of page 1

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

View Full Document Right 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));
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 )
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern