LEC07_Notes - 1 14:440:127 Introduction to Computers for...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: 1 14:440:127 Introduction to Computers for Engineers Notes for Lecture 07 Rutgers University, Spring 2011 Instructor - Brenda V. Cortez 1 Introduction In LEC01-LEC03 Notes you learned the C++ code syntax for five core programming concepts, and you also learned how to implement them; those concepts are: variables & their data types , selection code structures , loop code structures , both of which make you control flow , arrays , and user defined functions . Then in LEC04-LEC06 Notes you were introduced to the MatLab syntax for implementing all these same programming concepts. With LEC07 Notes we will continue learning the MatLab syntax and so, for these particular lecture notes, we will focus on plotting. We will then see how we can interact with users through a plot, about some of the most com- mon plot functions you need to become familiar with and we will finish by learning about another form of storing data in MatLab - using a structure , which was not covered in C++, but is a concept that becomes very useful in object oriented programming . Before moving to the various MatLab plot choices we have, lets take a step back and recall the in- troduction to simple plots that was given in the previous LEC06 notes, when the topic of animation was covered, and lets elaborate on it a bit further. 1.1 MatLab Functions Following are the MatLab functions you will need to know how to use: plot axis length get linspace text xlim legend fplot ezplot hold grid xlabel min colormap max ylim figure title ylabel hist area meshc max num2str bar gtext subplot loglog bar3h bar3 plot3 comet3 pie semilogx stem pie3 semilogy pcolor bar3h struct ginput shading mesh contour surf surfc 2 Review 2.1 Simple Plots - 2D Recall that when you want to plot in MatLab, you use the plot function, to which you have to pass at least one variable, but mostly two, i.e plot(x,y) . The first variable is a vector array of values for the x-axis and the second variable is a vector array of values for the y-axis . Of course, these vectors MUST be the same size- you wouldnt have an x-coordinate value and not a corresponding y-coordinate value, even if it was zero. 2 When plotting, there are many ways to customize the look of your plot. As you may remem- ber, you can specify the color by placing the letter character representing the color : b blue g green r red c cyan m magenta y yellow k black w white after the data you are plotting - plot(x,y,r) . You also learned that you can use a charac- ter markers to denote each point pair on your plot, plot(x,y,r*) : o circle x x-mark + plus * star s square d diamond v triangle (down)... With this information, lets plot a single pair of points, ( x 1 ,y 1 ), using a red square....
View Full Document

Page1 / 41

LEC07_Notes - 1 14:440:127 Introduction to Computers for...

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

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