This is a static copy of a profile reportHome
interp2>linear (189 calls, 1.102 sec)
Generated 05-Nov-2014 07:52:42 using cpu time.
subfunction in file /usr1/opt/matlab/7.13/toolbox/matlab/polyfun/interp2.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
interp2 | function | 189 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
338 | F = ( arg3(ndx).*(onemt) + ar... | 189 | 0.481 s | 43.6% |  |
323 | ndx = floor(t)+floor(s-1)*nrow... | 189 | 0.140 s | 12.7% |  |
303 | t = 1 + (arg5-arg2(1))/(arg2(e... | 189 | 0.140 s | 12.7% |  |
315 | sout = find((s<1)|(s>nco... | 189 | 0.070 s | 6.4% |  |
327 | s(:) = (s - floor(s)); | 189 | 0.060 s | 5.5% |  |
All other lines | | | 0.210 s | 19.1% |  |
Totals | | | 1.102 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 102 |
Non-code lines (comments, blank lines) | 47 |
Code lines (lines that can run) | 55 |
Code lines that did run | 30 |
Code lines that did not run | 25 |
Coverage (did run/can run) | 54.55 % |
Function listing
time calls line
246 function F = linear(ExtrapVal,arg1,arg2,arg3,arg4,arg5)
247 %LINEAR 2-D bilinear data interpolation.
248 % ZI = LINEAR(EXTRAPVAL,X,Y,Z,XI,YI) uses bilinear interpolation to
249 % find ZI, the values of the underlying 2-D function in Z at the points
250 % in matrices XI and YI. Matrices X and Y specify the points at which
251 % the data Z is given. X and Y can also be vectors specifying the
252 % abscissae for the matrix Z as for MESHGRID. In both cases, X
253 % and Y must be equally spaced and monotonic.
254 %
255 % Values of EXTRAPVAL are returned in ZI for values of XI and YI that are
256 % outside of the range of X and Y.
257 %
258 % If XI and YI are vectors, LINEAR returns vector ZI containing
259 % the interpolated values at the corresponding points (XI,YI).
260 %
261 % ZI = LINEAR(EXTRAPVAL,Z,XI,YI) assumes X = 1:N and Y = 1:M, where
262 % [M,N] = SIZE(Z).
263 %
264 % ZI = LINEAR(EXTRAPVAL,Z,NTIMES) returns the matrix Z expanded by
265 % interleaving bilinear interpolates between every element, working
266 % recursively for NTIMES. LINEAR(EXTRAPVAL,Z) is the same as
267 % LINEAR(EXTRAPVAL,Z,1).
268 %
269 % See also INTERP2, CUBIC.
270
189 271 if nargin==2 % linear(extrapval,z), Expand Z
272 [nrows,ncols] = size(arg1);
273 s = 1:.5:ncols; lengths = length(s);
274 t = (1:.5:nrows)'; lengtht = length(t);
275 s = repmat(s,lengtht,1);
276 t = repmat(t,1,lengths);
277
189 278 elseif nargin==3 % linear(extrapval,z,n), Expand Z n times
279 [nrows,ncols] = size(arg1);
280 ntimes = floor(arg2);
281 s = 1:1/(2^ntimes):ncols; lengths = length(s);
282 t = (1:1/(2^ntimes):nrows)'; lengtht = length(t);
283 s = repmat(s,lengtht,1);
284 t = repmat(t,1,lengths);
285
189 286 elseif nargin==4 % linear(extrapval,z,s,t), No X or Y specified.
287 [nrows,ncols] = size(arg1);
288 s = arg2; t = arg3;
289
189 290 elseif nargin==5
291 error(message('MATLAB:interp2:linear:nargin'));
292
189 293 elseif nargin==6 % linear(extrapval,x,y,z,s,t), X and Y specified.
189 294 [nrows,ncols] = size(arg3);
189 295 mx = numel(arg1); my = numel(arg2);
0.01 189 296 if (mx ~= ncols || my ~= nrows) && ~isequal(size(arg1),size(arg2),size(arg3))
297 error(message('MATLAB:interp2:linear:XYZLengthMismatch'));
298 end
189 299 if nrows < 2 || ncols < 2
300 error(message('MATLAB:interp2:linear:sizeZ'));
301 end
0.06 189 302 s = 1 + (arg4-arg1(1))/(arg1(end)-arg1(1))*(ncols-1);
0.14 189 303 t = 1 + (arg5-arg2(1))/(arg2(end)-arg2(1))*(nrows-1);
304
189 305 end
306
189 307 if nrows < 2 || ncols < 2
308 error(message('MATLAB:interp2:linear:sizeZsq'));
309 end
0.01 189 310 if ~isequal(size(s),size(t))
311 error(message('MATLAB:interp2:linear:XIandYISizeMismatch'));
312 end
313
314 % Check for out of range values of s and set to 1
0.07 189 315 sout = find((s<1)|(s>ncols));
189 316 if ~isempty(sout), s(sout) = 1; end
317
318 % Check for out of range values of t and set to 1
0.03 189 319 tout = find((t<1)|(t>nrows));
189 320 if ~isempty(tout), t(tout) = 1; end
321
322 % Matrix element indexing
0.14 189 323 ndx = floor(t)+floor(s-1)*nrows;
324
325 % Compute intepolation parameters, check for boundary value.
0.03 189 326 if isempty(s), d = s; else d = find(s==ncols); end
0.06 189 327 s(:) = (s - floor(s));
189 328 if ~isempty(d), s(d) = s(d)+1; ndx(d) = ndx(d)-nrows; end
329
330 % Compute intepolation parameters, check for boundary value.
0.01 189 331 if isempty(t), d = t; else d = find(t==nrows); end
0.03 189 332 t(:) = (t - floor(t));
0.01 189 333 if ~isempty(d), t(d) = t(d)+1; ndx(d) = ndx(d)-1; end
334
335 % Now interpolate.
0.01 189 336 onemt = 1-t;
189 337 if nargin==6,
0.48 189 338 F = ( arg3(ndx).*(onemt) + arg3(ndx+1).*t ).*(1-s) + ...
339 ( arg3(ndx+nrows).*(onemt) + arg3(ndx+(nrows+1)).*t ).*s;
340 else
341 F = ( arg1(ndx).*(onemt) + arg1(ndx+1).*t ).*(1-s) + ...
342 ( arg1(ndx+nrows).*(onemt) + arg1(ndx+(nrows+1)).*t ).*s;
343 end
344
345 % Now set out of range values to ExtrapVal.
189 346 if ~isempty(sout), F(sout) = ExtrapVal; end
189 347 if ~isempty(tout), F(tout) = ExtrapVal; end
Other subfunctions in this file are not included in this listing.