12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

x 294x1 ...y 294x1 ...z 294x1 ...Gr<strong>and</strong> total is 1111 elements>> plot3(x,y,z,’.’)>> axis tightHere we have 294 measurements <strong>of</strong> x (latitude), y (longitude), <strong>and</strong> z(height above sea level, which is negative). They represent measurements<strong>of</strong> a mountain under the sea. 17 The data are stored as column vectors<strong>of</strong> x, y, <strong>and</strong> z values. Suppose we want to plot a surface <strong>and</strong> a contourmap representing this seamount data. If you try to type surf(x,y,z)or contour(x,y,z) with this data, you will not get any meaningful plot.Two ways <strong>of</strong> generating the desired plots are as follows:1. Interpolate the data over a rectangular grid.2. Use triangular gridding instead <strong>of</strong> rectangular gridding.Let us look at each <strong>of</strong> these.36.1 Interpolation over a Rectangular GridWe continue the example above <strong>and</strong> define vectors <strong>of</strong> uniformly spacedpoints between the minimum <strong>and</strong> maximum values <strong>of</strong> x <strong>and</strong> y:xiv = linspace(min(x),max(x),50);yiv = linspace(min(y),max(y),50);Each <strong>of</strong> these vectors has 50 elements. We now use the griddata interpolationfunction to do two things: (1) create matrices <strong>of</strong> the x <strong>and</strong> ygrids that correspond to a rectangular grid over the vectors xiv <strong>and</strong> yiv,<strong>and</strong> (2) interpolate the data over this new rectangular grid. In the callto griddata that follows, we need to transpose the vector yiv becausegriddata expects it to be a column vector in this case:>> [xi,yi,zi] = griddata(x,y,z,xiv,yiv’);>> whosName Size Bytes Classcaption 1x229 458 char array17 The reference can be found by typing the caption variable:>> captioncaption=Parker, R. L., Shure, L. & Hildebr<strong>and</strong>, J., "The application <strong>of</strong> inversetheory to seamount magnetism", Reviews <strong>of</strong> Geophysics vol 25, pp 17-40,1987. x is latitude (degrees), y is longitude (degrees), z is negativedepth (meters).c○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!