forked from e0404/matRad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matRad_interp3.m
54 lines (47 loc) · 1.46 KB
/
matRad_interp3.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function y = matRad_interp3(xi,yi,zi,x,xq,yq,zq,mode,extrapVal)
% interpolates 3-D data (table lookup)
%
% call
% y = matRad_interp3(xi,yi,zi,x,xq,yq,zy)
% y = matRad_interp3(xi,yi,zi,x,xq,yq,zy,mode)
% y = matRad_interp3(xi,yi,zi,x,xq,yq,zy,mode,extrapVal)
%
% input
% xi,yi,zi: grid vectors
% x: data
% xq,yq,zq: coordinates of quer points as a grid
% mode: optional interpolation mode (default linear)
% extrapVal: (optional) value for extrapolation
%
% output
% y: interpolated data
%
% References
% -
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2019 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[env, ~] = matRad_getEnvironment();
if nargin < 8
mode = 'linear';
end
if nargin < 9
extrapVal = NaN;
end
switch env
case 'MATLAB'
y = interp3(xi,yi,zi,x,xq,yq,zq,mode,extrapVal);
case 'OCTAVE'
[xqMesh,yqMesh,zqMesh] = meshgrid(xq,yq,zq);
y = interp3(xi,yi,zi,x,xqMesh,yqMesh,zqMesh,mode,extrapVal);
end