21.01.2015 Views

COMSOL Multiphysics™

COMSOL Multiphysics™

COMSOL Multiphysics™

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.

elinterp<br />

Purpose<br />

elinterp<br />

Declare interpolation functions.<br />

Syntax<br />

Description<br />

el.elem = 'elinterp'<br />

el.name = fname<br />

el.x = xgrid<br />

el.y = ygrid<br />

el.z = zgrid<br />

el.data = fdata<br />

el.method = 'nearest' | 'linear' | 'cubic' | 'spline'<br />

The elinterp element declares an interpolation function based on a 1D, 2D or 3D<br />

data set provided by the user. Interpolation functions take one, two or three<br />

arguments, depending on the dimension of the data set.<br />

The xgrid, ygrid and zgrid parameters are cell arrays of points, sorted in<br />

increasing order, where the data is given. Depending on the dimensions, not all<br />

fields are used. For 1D interpolation, the fdata parameter is a cell array of values<br />

corresponding to the points in el.x. In the 2D case, the size of fdata is<br />

length(xgrid)*length(ygrid), with x increasing fastest, and similarly in 3D.<br />

There are four interpolation methods to choose from. Nearest neighbor and linear<br />

interpolation are available in all dimensions, while 'cubic' and 'spline' can only<br />

be used for interpolation in 1D data sets. The difference between the latter two is,<br />

generally speaking, that 'cubic' preserves monotonicity and does not overshoot at<br />

the cost of discontinuous second derivatives at the tying points.<br />

Cautionary<br />

Examples<br />

Interpolation is provided only for real numbers. To interpolate complex numbers,<br />

real and imaginary parts have to be treated separately.<br />

Given the matrices x (1-by-m), y (1-by-n) and F (m-by-n), create a corresponding<br />

interpolation element declaring a function f(x,y).<br />

cellX = cell(1,m);<br />

for i=1:m<br />

cellX{i} = num2str(x(i));<br />

end<br />

cellY = cell(1,n);<br />

for i=1:n<br />

cellY{i} = num2str(y(i));<br />

end<br />

cellF = cell(1,m*n);<br />

for i=1:m*n<br />

cellF{i} = num2str(F(i));<br />

end<br />

84 | CHAPTER 1: COMMAND REFERENCE

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

Saved successfully!

Ooh no, something went wrong!