Page 376 - Process Modelling and Simulation With Finite Element Methods
P. 376
A MATLAB/FEMLAB Primer for Vector Calculus 363
Figure A3 shows the contours of 0 = x2 + y2 = c for several different values
of the constant C. MATLA B has no data type to represent a field quantity.
Rather, such quantities are represented as functions. There are three major ways
of representing a function in MATLAB
(1) An inline function, defined only in the workspace
>> myfun = 'l+log(r) ;
1
>> myfuni=inline(myfun, 'r')
myfuni =
Inline function:
myfuni (r) = l+log (r)
>> a=feval(myfuni,l)
a=
1
>> a=feval (myfuni,lO)
a=
3.3026
(2) An m-file function, which is stored as a disk file and can be called from
either the workspace or an m-file script. For instance the m-file function
temperat.m contains the following code and is stored in the MATLAB
current directory.
function t=temperat (r)
%TEMPEMT evaluates T = 1 + In r
% T = temperat(r)
,
t=l+log (r)
;
>>a=temperat (10)
a=
3.3026
(3) Interpolation functions. The values of the function at certain points are
specified. Values at nearby points are estimated by assumption about how
smooth the function is locally. Interpolation requires a series of MATLAB
commands, but eventually results in a functional form. MATLAB has built-
in functions for I-D and 2-D data. The Rock Fracture Model in the
FEMLAB Model Library (FEMLAB/Geophysics/rock-fracture) uses 2-D
interpolation of a supplied dataset in a MATLAB mat-file, as an m-file
function (flafun.m) that does 2-D interpolation:
function a=flafun(x,y)
%FLAFUN Interpolate aperture from sampled data.
% A = FLAFUN(X,Y) interpolates rock fracture aperture from sampled
data.
% X and Y are coordinates for node points in an unstructured grid.
% A is the interpolated aperture in the the node points.
%
% FLAFUN is a function used as diffusion coefficient in the
geophysics
% ROCK-FRACTURE model in the Model Library.

