intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Lecture note Data visualization - Chapter 28

Chia sẻ: Minh Nhật | Ngày: | Loại File: PPTX | Số trang:16

13
lượt xem
1
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

The main contents of the chapter consist of the following: Functions with no input or no output, determining the number of input and output arguments, local variables, global variables, creating toolbox of functions, anonymous functions and function handles, function functions, subfunctions.

Chủ đề:
Lưu

Nội dung Text: Lecture note Data visualization - Chapter 28

  1. Lecture 28
  2. Recap  Functions with No input OR No output  Determining The Number of Input and Output Arguments Local Variables Global Variables  Creating ToolBox of Functions Anonymous Functions and Function Handles  Function Functions Subfunctions
  3. Summary of Chapter  MATLAB contains a wide variety of built­in functions However, you will often find it useful to create your own  MATLAB functions The most common type of user­defined MATLAB  function is the function M­file, which must start with a  function­definition line that contains the word function  a variable that defines the function output a function name a variable used for the input argument
  4. Continued…. The function name must also be the name of the M­file in  which the function is stored Function names follow the standard MATLAB naming  rules Like the built­in functions, user­defined functions can  accept multiple inputs and can return multiple results Comments immediately following the function­definition  line can be accessed from the command window with the  help command Variables defined within a function are local to that  function. They are not stored in the workspace and cannot 
  5. Continued…. Groups of user­defined functions, called “toolboxes,” may  be stored in a common directory and accessed by  modifying the MATLAB® search path. This is  accomplished interactively with the path tool, either from  the menu bar, as in File ­> Set Path       or from the command line, with pathtool MATLAB provides access to numerous toolboxes  developed at The MathWorks or by the user community Another type of function is the anonymous function, 
  6. Chapter 13  Numerical Techniques 
  7. Introduction  Interpolate between data points, using either linear or  cubic spline models Model a set of data points as a polynomial Use the basic fitting tool Use the curve­fitting toolbox Perform numerical differentiations Perform numerical integrations Solve differential equations numerically
  8. Interpolation  Especially when we measure things, we don’t gather data  at every possible data point Consider a set of x–y data collected during an experiment By using an interpolation technique, we can estimate the  value of y at values of x where we didn’t take  measurement The two most common interpolation techniques are  Linear interpolation  Cubic spline interpolation
  9. Interpolation between  data points 
  10. Linear Interpolation The most common way to estimate a data point between  two known points is linear interpolation In this technique, we assume that the function between the  points can be estimated by a straight line drawn between  them If we find the equation of a straight line defined by the  two known points, we can find y for any value of x  The closer together the points are, the more accurate our  approximation is likely to be
  11. Continued…. We can perform linear interpolation in MATLAB with the  interp1 function We’ll first need to create a set of ordered pairs to use as  input to the function The data used to create the right­hand graph of next figure  is  x = 0:5; y = [15, 10, 9, 6, 2, 0];
  12. Continued…. To perform a single interpolation, the input to interp1 is  the x data, the y data, and the new x value for which you’d  like an estimate of y  For example: to estimate the value of y when x is equal  to 3.5, type interp1(x,y,3.5) ans = 4 You can perform multiple interpolations all at the same  time by putting a vector of x ­values in the third field of  the interp1 function For example: to estimate y ­values for new x ’s spaced  evenly from 0 to 5 by 0.2, type
  13. Continued…. The interp1 function defaults to linear interpolation to  make its estimates. However, other approaches are  possible If we want (probably for documentation purposes) to  explicitly define the approach used in interp1 as linear  interpolation, we can specify it in a fourth field: interp1(x, y, 3.5, 'linear') ans = 4
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2