comparison scripts/polynomial/polyfit.m @ 7547:40ca9fb9a314

polyfit.m: Fixed tests.
author Ben Abbott <bpabbott@mac.com>
date Tue, 04 Mar 2008 14:02:53 -0500
parents 83cce070104f
children 6f2d95255911
comparison
equal deleted inserted replaced
7546:4249c6fb6e09 7547:40ca9fb9a314
138 %! y = [ 315571.7086, 315575.9618, 315579.4195, 315582.6206, 315585.4966, \ 138 %! y = [ 315571.7086, 315575.9618, 315579.4195, 315582.6206, 315585.4966, \
139 %! 315588.3172, 315590.9326, 315593.5934, 315596.0455, 315598.4201, \ 139 %! 315588.3172, 315590.9326, 315593.5934, 315596.0455, 315598.4201, \
140 %! 315600.7143, 315602.9508, 315605.1765 ]; 140 %! 315600.7143, 315602.9508, 315605.1765 ];
141 %! [p1, s1] = polyfit (x, y, 10); 141 %! [p1, s1] = polyfit (x, y, 10);
142 %! [p2, s2, mu] = polyfit (x, y, 10); 142 %! [p2, s2, mu] = polyfit (x, y, 10);
143 %! assert (s1.normr, 0.11264, 0.1) 143 %! assert (2*s2.normr < s1.normr)
144 %! assert (s2.normr < s1.normr)
145 144
146 %!test 145 %!test
147 %! x = 1:4; 146 %! x = 1:4;
148 %! p0 = [1i, 0, 2i, 4]; 147 %! p0 = [1i, 0, 2i, 4];
149 %! y0 = polyval (p0, x); 148 %! y0 = polyval (p0, x);
158 %! [p, s, mu] = polyfit (x, y, numel(pn)-1); 157 %! [p, s, mu] = polyfit (x, y, numel(pn)-1);
159 %! [p2, s2] = polyfit (x, y, numel(pn)-1); 158 %! [p2, s2] = polyfit (x, y, numel(pn)-1);
160 %! assert (p, pn, s.normr) 159 %! assert (p, pn, s.normr)
161 %! assert (s.yf, y, s.normr) 160 %! assert (s.yf, y, s.normr)
162 %! assert (mu, [mean(x), std(x)]) 161 %! assert (mu, [mean(x), std(x)])
163 %! assert (s.normr/s2.normr < 1e-9) 162 %! assert (s.normr/s2.normr < sqrt(eps))
164 163
165 %!test 164 %!test
166 %! x = [1, 2, 3; 4, 5, 6]; 165 %! x = [1, 2, 3; 4, 5, 6];
167 %! y = [0, 0, 1; 1, 0, 0]; 166 %! y = [0, 0, 1; 1, 0, 0];
168 %! p = polyfit (x, y, 5); 167 %! p = polyfit (x, y, 5);