28.12.2012 Views

Figure Properties - SERC

Figure Properties - SERC

Figure Properties - SERC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

interp2<br />

spacing is handled by mapping the given values in X, Y, XI, and YI to an equally<br />

spaced domain before interpolating. For faster interpolation when X and Y are<br />

equally spaced and monotonic, use the methods '*linear', '*cubic',<br />

'*spline', or '*nearest'.<br />

ZI = interp2(...,method, extrapval) specificies a method and a scalar<br />

value for ZI outside of the domain created by X and Y. Thus, ZI equals<br />

extrapval for any value of YI or XI that is not spanned by Y or X respectively.<br />

A method must be specified to use extrapval. The default method is 'linear'.<br />

Remarks The interp2 command interpolates between data points. It finds values of a<br />

two-dimensional function fxy ( , ) underlying the data at intermediate points.<br />

f(x,y)<br />

Interpolated points P(XI,YI,ZI)<br />

Grid points P(X,Y,Z)<br />

Interpolation is the same operation as table lookup. Described in table lookup<br />

terms, the table is tab = [NaN,Y; X,Z] and interp2 looks up the elements of<br />

XI in X, YI in Y, and, based upon their location, returns values ZI interpolated<br />

within the elements of Z.<br />

Examples Example 1. Interpolate the peaks function over a finer grid.<br />

[X,Y] = meshgrid(-3:.25:3);<br />

Z = peaks(X,Y);<br />

[XI,YI] = meshgrid(-3:.125:3);<br />

ZI = interp2(X,Y,Z,XI,YI);<br />

mesh(X,Y,Z), hold, mesh(XI,YI,ZI+15)<br />

hold off<br />

axis([-3 3 -3 3 -5 20])<br />

2-1195

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

Saved successfully!

Ooh no, something went wrong!