This is a static copy of a profile reportHome
polyfun/private/chckxy (25 calls, 0.033 sec)
Generated 05-Aug-2011 13:00:54 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/polyfun/private/chckxy.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
spline | function | 7 |
pchip | function | 18 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
49 | if any(dx<0), [x,ind] = sor... | 25 | 0.011 s | 33.3% |  |
35 | if ~isempty(nanx) | 25 | 0.011 s | 33.3% |  |
34 | nanx = find(isnan(x)); | 25 | 0.011 s | 33.3% |  |
101 | if ~isempty(nany) | 25 | 0 s | 0% |  |
100 | nany = find(sum(isnan(y),1)); | 25 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0.033 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 108 |
Non-code lines (comments, blank lines) | 47 |
Code lines (lines that can run) | 61 |
Code lines that did run | 26 |
Code lines that did not run | 35 |
Coverage (did run/can run) | 42.62 % |
Function listing
time calls line
1 function [x,y,sizey,endslopes] = chckxy(x,y)
2 %CHCKXY check and adjust input for SPLINE and PCHIP
3 % [X,Y,SIZEY] = CHCKXY(X,Y) checks the data sites X and corresponding data
4 % values Y, making certain that there are exactly as many sites as values,
5 % that no two data sites are the same, removing any data points that involve
6 % NaNs, reordering the sites if necessary to ensure that X is a strictly
7 % increasing row vector and reordering the data values correspondingly,
8 % and reshaping Y if necessary to make sure that it is a matrix, with Y(:,j)
9 % the data value corresponding to the data site X(j), and with SIZEY the
10 % actual dimensions of the given values.
11 % This call to CHCKXY is suitable for PCHIP.
12 %
13 % [X,Y,SIZEY,ENDSLOPES] = CHCKXY(X,Y) also considers the possibility that
14 % there are two more data values than there are data sites.
15 % If there are, then the first and the last data value are removed from Y
16 % and returned separately as ENDSLOPES. Otherwise, an empty ENDSLOPES is
17 % returned. This call to CHCKXY is suitable for SPLINE.
18 %
19 % See also PCHIP, SPLINE.
20
21 % Copyright 1984-2003 The MathWorks, Inc.
22
23 % make sure X is a vector:
25 24 if length(find(size(x)>1))>1
25 error(message('MATLAB:chckxy:XNotVector'))
26 end
27
28 % ensure X is real
25 29 if any(~isreal(x))
30 error(message('MATLAB:chckxy:XComplex'))
31 end
32
33 % deal with NaN's among the sites:
0.01 25 34 nanx = find(isnan(x));
0.01 25 35 if ~isempty(nanx)
36 x(nanx) = [];
37 warning(message('MATLAB:chckxy:nan'))
38 end
39
25 40 n=length(x);
25 41 if n<2
42 error(message('MATLAB:chckxy:NotEnoughPts'))
43 end
44
45 % re-sort, if needed, to ensure strictly increasing site sequence:
25 46 x=x(:).';
25 47 dx = diff(x);
48
0.01 25 49 if any(dx<0), [x,ind] = sort(x); dx = diff(x); else ind=1:n; end
50
25 51 if ~all(dx), error(message('MATLAB:chckxy:RepeatedSites')), end
52
53 % if Y is ND, reshape it to a matrix by combining all dimensions but the last:
25 54 sizey = size(y);
55
56
25 57 while length(sizey)>2&&sizey(end)==1, sizey(end) = []; end
58
59
25 60 yn = sizey(end);
25 61 sizey(end)=[];
25 62 yd = prod(sizey);
63
25 64 if length(sizey)>1
65 y = reshape(y,yd,yn);
25 66 else
67 % if Y happens to be a column matrix, change it to the expected row matrix.
25 68 if yn==1
69 yn = yd;
70 y = reshape(y,1,yn);
71 yd = 1;
72 sizey = yd;
73 end
25 74 end
75
76 % determine whether not-a-knot or clamped end conditions are to be used:
25 77 nstart = n+length(nanx);
25 78 if yn==nstart
25 79 endslopes = [];
80 elseif nargout==4&&yn==nstart+2
81 endslopes = y(:,[1 n+2]); y(:,[1 n+2])=[];
82 if any(isnan(endslopes))
83 error(message('MATLAB:chckxy:EndslopeNaN'))
84 end
85 if any(isinf(endslopes))
86 error(message('MATLAB:chckxy:EndslopeInf'))
87 end
88 else
89 error('MATLAB:chckxy:NumSitesMismatchValues',...
90 ['The number of sites, ' int2str(nstart), ...
91 ', is incompatible with the number of values, ' int2str(yn) '.'])
92 end
93
94 % deal with NaN's among the values:
25 95 if ~isempty(nanx)
96 y(:,nanx) = [];
97 end
98
25 99 y=y(:,ind);
25 100 nany = find(sum(isnan(y),1));
25 101 if ~isempty(nany)
102 y(:,nany) = []; x(nany) = [];
103 warning(message('MATLAB:chckxy:IgnoreNaN'))
104 n = length(x);
105 if n<2
106 error(message('MATLAB:chckxy:NotEnoughPts'))
107 end
108 end
Other subfunctions in this file are not included in this listing.