Chapter 5_Plot.P2.ppt - Introduction to Computer for...

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

View Full Document Right Arrow Icon
Plotting Introduction to Computer for Engineers
Image of page 1

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

View Full Document Right Arrow Icon
plot (x,y) is used to plot a function y=f(x), plots the x values on the horizontal axis and the y values on the vertical axis. xlabel (‘text’) and ylabel (‘text’): put labels on horizontal and vertical axis. title (‘text’): puts a title at the top of the plot.
Image of page 2
Image of page 3

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

View Full Document Right Arrow Icon
>> x=[0:0.1:52]; >> y=0.4*sqrt(1.8*x); >> plot(x,y) >> xlabel('Distance (miles)') >> ylabel('Height (miles)') >> title('Rocket height as a function of Downrange Distance') Practice: Draw y=sin(x) , z=2cos(x) and t=y+z with 0 x 180 0
Image of page 4
grid: displays gridlines at the tick marks corresponding to the tick labels. grid on: add gridlines grid off: stop plotting gridlines axis: override the Matlab selections for the axis limits. axis ([xmin xmax ymin ymax]): sets the scaling for the x- and y- axes to the minimum and maximum values indicated, not use commas to separate the values. Practice: Given y=sin (x) , z=2cos(x) and t=y+z . Draw t using grid, axis. (the limit on x and y are optional.)
Image of page 5

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

View Full Document Right Arrow Icon
The axis command has the following variants: axis square : selects the axes’ limits so that the plot will be square. axis equal : selects the scale factors and tick spacing to be the same on each axis. This makes plot(sin(x),cos(x)) look like a circle, instead of an oval. axis auto : returns the axis scaling to its default autoscaling mode in which the best axes limits are computed automatically.
Image of page 6
>> x=[0:0.1:52]; >> y=0.4*sqrt(1.8*x); >> plot(x,y), xlabel('Distance (miles)'), ylabel('Height (miles)'), title('Rocket height as a function of Downrange Distance'), grid on, axis ([0 52 0 5])
Image of page 7

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

View Full Document Right Arrow Icon
fplot (‘string’, [xmin xmax]) ‘string’: a text string, describes the function to be plotted [xmin xmax]: specifies the minimum and maximum values of the independent variable. The range of the dependent variable can also be specified: fplot (‘string’, [xmin xmax ymin ymax]) [x,y]= fplot (‘string’, limits) limits may be [xmin xmax] or [xmin xmax ymin ymax]
Image of page 8
>> x=[1:0.01:2]; >> y=cos(tan(x))-tan(sin(x)); >> plot(x,y) >> f='cos(tan(x))-tan(sin(x))'; >> fplot(f,[1 2])
Image of page 9

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

View Full Document Right Arrow Icon
polyval : plot polynomials. (Chapter 2) Ex: 6 6 , 90 7 2 100 2 3 2 3 4 5 x x x x x x >> x=[-6:0.01:6]; >> p=[3,2,-100,2,-7,90]; >> plot(x,polyval(p,x)),xlabel('x'),ylabel('p')
Image of page 10
1.
Image of page 11

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

View Full Document Right Arrow Icon
Image of page 12
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