Chapter 5_Plot.P2.ppt

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

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

Plotting Introduction to Computer for Engineers

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

View Full Document
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.

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

View Full Document
>> 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
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.)

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

View Full Document
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.
>> 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])

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

View Full Document
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]
>> 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])

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

View Full Document
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')
1.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern