EVALPDF evaluates a PDF struct by interpolation CALL: f = evalpdf(pdf,x1,x2,...,xd,method) f = evaluated pdf at x1,x2,...,xd pdf = PDF structure x1,x2,...,xd = vectors/matrices of points where the pdf is evaluated method = 'nearest' - nearest neighbor interpolation 'linear' - linear interpolation (default) 'spline' - cubic spline interpolation 'cubic' - cubic interpolation For faster interpolation when pdf.x{1},... pdf.x{d} are equally spaced and monotonic, use the methods '*linear', '*cubic', or '*nearest'. Out of range values are returned as NaN's. See also datastructures
Create cell array. | |
Deal inputs to outputs. | |
Display message and abort function. | |
1-D interpolation (table lookup) | |
2-D interpolation (table lookup). | |
3-D interpolation (table lookup). | |
N-D interpolation (table lookup). | |
True for structures. | |
X and Y arrays for 3-D plots. | |
Generation of arrays for N-D functions and interpolation. |
Binned Kernel Density Estimator. | |
setup all global variables of the RECDEMO | |
Transform joint T-H density to V-H density | |
Joint distribution (pdf) of crest front velocity and wave height: | |
Joint distribution (pdf) of crest front period, Tcf, and crest amplitude, Ac |
001 function fi = evalpdf(pdf,varargin) 002 % EVALPDF evaluates a PDF struct by interpolation 003 % 004 % CALL: f = evalpdf(pdf,x1,x2,...,xd,method) 005 % 006 % f = evaluated pdf at x1,x2,...,xd 007 % pdf = PDF structure 008 % x1,x2,...,xd = vectors/matrices of points where the pdf is evaluated 009 % method = 'nearest' - nearest neighbor interpolation 010 % 'linear' - linear interpolation (default) 011 % 'spline' - cubic spline interpolation 012 % 'cubic' - cubic interpolation 013 % 014 % For faster interpolation when pdf.x{1},... pdf.x{d} are equally spaced and 015 % monotonic, use the methods '*linear', '*cubic', or '*nearest'. 016 % Out of range values are returned as NaN's. 017 % 018 % See also datastructures 019 if isstruct(pdf) 020 d=ndims(pdf.f); 021 022 if d==2 023 fsiz=size(pdf.f); 024 if min(fsiz)==1 025 d=1; 026 end 027 end 028 else 029 error('pdf must be a structure') 030 end 031 Xi=cell(d,1); 032 [Xi{1:d}]=deal(varargin{1:d}); 033 nv=length(varargin); 034 if d<nv, 035 method=varargin{nv}; 036 else 037 method='linear'; 038 end 039 switch d 040 case 1, 041 fi = interp1(pdf.x{1},pdf.f,Xi{1},method); 042 case 2, 043 X=cell(d,1); 044 [X{:}] = meshgrid(pdf.x{:}); 045 fi =interp2(X{:},pdf.f,Xi{:},method); 046 case 3, 047 X=cell(d,1); 048 [X{:}] = meshgrid(pdf.x{:}); 049 fi =interp3(X{:},pdf.f,Xi{:},method); 050 otherwise , 051 disp('Dimension of data large, this will take a while.') 052 [X{:}] = ndgrid(pdf.x{:}); 053 fi =interpn(X{:},pdf.f,Xi{:},method); 054 end 055
Comments or corrections to the WAFO group