L06_Plotting_Matlab

# L06_Plotting_Matlab - Announcements ChE Barbeque Wed 5:30...

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

Announcements ChE Barbeque, Wed. 5:30, Olin Terrace

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

View Full Document
Challenge 1 is Due Wednesday Submit one MS Word file in report format Incorporate your plots with your text in Word Place Matlab command files and Excel spreadsheets in an appendix
Click to edit Master subtitle style Plotting with Matlab Some commands for plotting graphs in Matlab: >> title (‘graph title') Titles the graph (put any- thing you want inside quotes) >> xlabel ('the x-axis label') Labels the x-axis >> ylabel ('the y-axis label') Labels the y-axis >> grid Superimposes grid onto a graph >> axis ([xmin xmax ymin ymax]) Sets axis ranges >> x= sin(0:0.1:10) Creates data set 'x‘ >> y= cos(0:0.1:10) Creates data set ‘y‘ >> z= tan(0:0.1:10) >> plot (x,y) Plots y vs. x >> plot (x,y,'*',x,z,':') Plots y vs. x using (********) and Plots z vs. x using (- - - - - -) Plot editor: choose insert from Menu bar to insert/modify plot elements Alternatively: use MATLAB function calls in command line

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

View Full Document
Plotting with Matlab (cont) >> x = 0 : 0.4 : 4*pi >> plot(x, y, ‘dr’) plots red diamonds >> plot(x,y, ‘-o’, ‘LineWidth’, 2, ‘MarkerSize’, 6) NOTE: property names always placed in quotes since they are strings (ordered sequence of symbols formatted in TeX – Table 1 p291) semilogx: log scale on x-axis loglog: log scale on both axes Subplot(m,n,pane_number): m=# of subwindow rows, n=# of subwindow columns
Click to edit Master subtitle style Curve Fitting in Matlab Matlab has two functions, polyfit and polyval , that fit a set of data points with a polynomial. The equation for a polynomial is: f(x)=a0xN+a1xN-1+a2xN-2+…+AN-1x+aN For a straight line, N=1, and the equation becomes: f(x) = a0x + a1 This is the same as our previously used equation for a straight line: y = mx + b We call a straight line a first degree polynomial equation because x in the equation is raised to the power of one. What is the degree of the following equation? f(x)=a0x4 + a1x3 + a2x2 + a3x + a4

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

View Full Document
Curve Fitting in Matlab (cont’d) Polyfit computes a least squares polynomial for a given set of data. It generates the coefficients of the polynomial, which can be used to model a curve to fit the data. Polyval evaluates a polynomial for a given set of x values.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/27/2009 for the course ES 140 taught by Professor Varies during the Spring '07 term at Vanderbilt.

### Page1 / 22

L06_Plotting_Matlab - Announcements ChE Barbeque Wed 5:30...

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

View Full Document
Ask a homework question - tutors are online