This is a static copy of a profile reportHome
interp3>linear (417 calls, 101.120 sec)
Generated 05-Nov-2014 07:52:41 using cpu time.
subfunction in file /usr1/opt/matlab/7.13/toolbox/matlab/polyfun/interp3.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
interp3 | function | 417 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
376 | F = (( arg4(ndx).*(1-t) + arg... | 417 | 63.087 s | 62.4% |  |
357 | ndx = floor(t)+floor(s-1)*nrow... | 417 | 8.692 s | 8.6% |  |
331 | t = 1 + (arg6-arg2(1))/(arg2(m... | 417 | 3.925 s | 3.9% |  |
330 | s = 1 + (arg5-arg1(1))/(arg1(m... | 417 | 3.855 s | 3.8% |  |
332 | w = 1 + (arg7-arg3(1))/(arg3(m... | 417 | 3.705 s | 3.7% |  |
All other lines | | | 17.855 s | 17.7% |  |
Totals | | | 101.120 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 145 |
Non-code lines (comments, blank lines) | 64 |
Code lines (lines that can run) | 81 |
Code lines that did run | 45 |
Code lines that did not run | 36 |
Coverage (did run/can run) | 55.56 % |
Function listing
time calls line
246 function F = linear(arg1,arg2,arg3,arg4,arg5,arg6,arg7,ExtrapVal)
247 %LINEAR 3-D trilinear data interpolation.
248 % VI = LINEAR(X,Y,Z,V,XI,YI,ZI) uses trilinear interpolation
249 % to find VI, the values of the underlying 3-D function in V
250 % at the points in arrays XI, YI and ZI. Arrays X, Y, and
251 % Z specify the points at which the data V is given. X, Y,
252 % and Z can also be vectors specifying the abscissae for the
253 % matrix V as for MESHGRID. In both cases, X, Y, and Z must be
254 % equally spaced and monotonic.
255 %
256 % Values of NaN are returned in VI for values of XI, YI and ZI
257 % that are outside of the range of X, Y, and Z.
258 %
259 % If XI, YI, and ZI are vectors, LINEAR returns vector VI
260 % containing the interpolated values at the corresponding
261 % points (XI,YI,ZI).
262 %
263 % VI = LINEAR(V,XI,YI,ZI) assumes X = 1:N, Y = 1:M, and
264 % Z = 1:P where [M,N,P] = SIZE(V).
265 %
266 % VI = LINEAR(V,NTIMES) returns the matrix VI expanded by
267 % interleaving bilinear interpolates between every element,
268 % working recursively for NTIMES. LINEAR(V) is the same
269 % as LINEAR(V,1).
270 %
271 % This function needs about 4 times SIZE(XI) memory to be
272 % available.
273 %
274 % See also INTERP3.
275
276 % find extrapolation value
417 277 switch nargin
417 278 case 1
279 ExtrapVal = arg1;
0.01 417 280 case 2
281 ExtrapVal = arg2;
417 282 case 3
283 ExtrapVal = arg3;
417 284 case 4
285 ExtrapVal = arg4;
417 286 case 5
287 ExtrapVal = arg5;
417 288 case 6
289 ExtrapVal = arg6;
417 290 case 7
291 ExtrapVal = arg7;
292 % case 8 is implicit
293 end
294
0.01 417 295 if nargin==2, % linear(v), Expand V
296 if ndims(arg1)~=3
297 error(message('MATLAB:interp3:linear:Vnot3Dnarg2'));
298 end
299 [nrows,ncols,npages] = size(arg1);
300 [s,t,w] = meshgrid(1:.5:ncols,1:.5:nrows,1:.5:npages);
301
417 302 elseif nargin==3, % linear(v,n), Expand V n times
303 if ndims(arg1)~=3
304 error(message('MATLAB:interp3:linear:Vnot3Dnarg2'));
305 end
306 [nrows,ncols,npages] = size(arg1);
307 ntimes = floor(arg2); delta = 1/(2^ntimes);
308 [s,t,w] = meshgrid(1:delta:ncols,1:delta:nrows,1:delta:npages);
309
417 310 elseif nargin==4 || nargin==6 || nargin==7
311 error(message('MATLAB:interp3:linear:ninput'));
312
0.01 417 313 elseif nargin==5, % linear(v,s,t,w), No X, Y or Z specified.
314 if ndims(arg1)~=3
315 error(message('MATLAB:interp3:linear:Vnot3Dnarg5'));
316 end
317 [nrows,ncols,npages] = size(arg1);
318 s = arg2; t = arg3; w = arg4;
319
0.01 417 320 elseif nargin==8, % linear(x,y,z,v,s,t,w), X, Y and Z specified.
417 321 if ndims(arg4)~=3
322 error(message('MATLAB:interp3:linear:Vnot3Dnarg8'));
323 end
417 324 [nrows,ncols,npages] = size(arg4);
417 325 mx = numel(arg1); my = numel(arg2); mz = numel(arg3);
0.02 417 326 if ~isequal([my mx mz],size(arg4)) && ...
327 ~isequal(size(arg1),size(arg2),size(arg3),size(arg4))
328 error(message('MATLAB:interp3:linear:XYZLengthMismatchV'));
329 end
3.86 417 330 s = 1 + (arg5-arg1(1))/(arg1(mx)-arg1(1))*(ncols-1);
3.93 417 331 t = 1 + (arg6-arg2(1))/(arg2(my)-arg2(1))*(nrows-1);
3.71 417 332 w = 1 + (arg7-arg3(1))/(arg3(mz)-arg3(1))*(npages-1);
333
0.09 417 334 end
335
0.02 417 336 if any([nrows ncols npages]<[2 2 2]),
337 error(message('MATLAB:interp3:linear:Vsize'));
338 end
0.03 417 339 if ~isequal(size(s),size(t),size(w))
340 error(message('MATLAB:interp3:linear:XIYIZISizeMismatch'));
341 end
342
343 % Check for out of range values of s and set to 1
1.49 417 344 sout = find((s<1)|(s>ncols));
0.01 417 345 if ~isempty(sout), s(sout) = ones(size(sout)); end
346
347 % Check for out of range values of t and set to 1
1.63 417 348 tout = find((t<1)|(t>nrows));
0.01 417 349 if ~isempty(tout), t(tout) = ones(size(tout)); end
350
351 % Check for out of range values of w and set to 1
1.78 417 352 wout = find((w<1)|(w>npages));
417 353 if ~isempty(wout), w(wout) = ones(size(wout)); end
354
355 % Matrix element indexing
417 356 nw = nrows*ncols;
8.69 417 357 ndx = floor(t)+floor(s-1)*nrows+floor(w-1)*nw;
358
359 % Compute intepolation parameters, check for boundary value.
1.28 417 360 if isempty(s), d = s; else d = find(s==ncols); end
3.33 417 361 s(:) = (s - floor(s));
0.10 417 362 if ~isempty(d), s(d) = s(d)+1; ndx(d) = ndx(d)-nrows; end
363
364 % Compute intepolation parameters, check for boundary value.
1.39 417 365 if isempty(t), d = t; else d = find(t==nrows); end
2.88 417 366 t(:) = (t - floor(t));
0.09 417 367 if ~isempty(d), t(d) = t(d)+1; ndx(d) = ndx(d)-1; end
368
369 % Compute intepolation parameters, check for boundary value.
0.88 417 370 if isempty(w), d = w; else d = find(w==npages); end
2.16 417 371 w(:) = (w - floor(w));
0.50 417 372 if ~isempty(d), w(d) = w(d)+1; ndx(d) = ndx(d)-nw; end
373
374 % Now interpolate.
417 375 if nargin==8,
63.09 417 376 F = (( arg4(ndx).*(1-t) + arg4(ndx+1).*t ).*(1-s) + ...
377 ( arg4(ndx+nrows).*(1-t) + arg4(ndx+(nrows+1)).*t ).*s).*(1-w) +...
378 (( arg4(ndx+nw).*(1-t) + arg4(ndx+1+nw).*t ).*(1-s) + ...
379 ( arg4(ndx+nrows+nw).*(1-t) + arg4(ndx+(nrows+1+nw)).*t ).*s).*w;
380 else
381 F = (( arg1(ndx).*(1-t) + arg1(ndx+1).*t ).*(1-s) + ...
382 ( arg1(ndx+nrows).*(1-t) + arg1(ndx+(nrows+1)).*t ).*s).*(1-w) +...
383 (( arg1(ndx+nw).*(1-t) + arg1(ndx+1+nw).*t ).*(1-s) + ...
384 ( arg1(ndx+nrows+nw).*(1-t) + arg1(ndx+(nrows+1+nw)).*t ).*s).*w;
385 end
386
387 % Now set out of range values to ExtrapVal.
0.03 417 388 if ~isempty(sout), F(sout) = ExtrapVal; end
0.01 417 389 if ~isempty(tout), F(tout) = ExtrapVal; end
0.02 417 390 if ~isempty(wout), F(wout) = ExtrapVal; end
Other subfunctions in this file are not included in this listing.