comparison scripts/polynomial/polyfit.m @ 11918:f2af2233ce7f release-3-0-x

polyfit.m: Fixed tests.
author Ben Abbott <bpabbott@mac.com>
date Mon, 12 Jan 2009 12:14:06 +0100
parents deb777a926ee
children
comparison
equal deleted inserted replaced
11917:deb777a926ee 11918:f2af2233ce7f
118 %! y = [ 315571.7086, 315575.9618, 315579.4195, 315582.6206, 315585.4966, \ 118 %! y = [ 315571.7086, 315575.9618, 315579.4195, 315582.6206, 315585.4966, \
119 %! 315588.3172, 315590.9326, 315593.5934, 315596.0455, 315598.4201, \ 119 %! 315588.3172, 315590.9326, 315593.5934, 315596.0455, 315598.4201, \
120 %! 315600.7143, 315602.9508, 315605.1765 ]; 120 %! 315600.7143, 315602.9508, 315605.1765 ];
121 %! [p1, s1] = polyfit (x, y, 10); 121 %! [p1, s1] = polyfit (x, y, 10);
122 %! [p2, s2, mu] = polyfit (x, y, 10); 122 %! [p2, s2, mu] = polyfit (x, y, 10);
123 %! assert (s1.normr, 0.11264, 0.1) 123 %! assert (2*s2.normr < s1.normr)
124 %! assert (s2.normr < s1.normr)
125 124
126 %!test 125 %!test
127 %! x = 1:4; 126 %! x = 1:4;
128 %! p0 = [1i, 0, 2i, 4]; 127 %! p0 = [1i, 0, 2i, 4];
129 %! y0 = polyval (p0, x); 128 %! y0 = polyval (p0, x);
138 %! [p, s, mu] = polyfit (x, y, numel(pn)-1); 137 %! [p, s, mu] = polyfit (x, y, numel(pn)-1);
139 %! [p2, s2] = polyfit (x, y, numel(pn)-1); 138 %! [p2, s2] = polyfit (x, y, numel(pn)-1);
140 %! assert (p, pn, s.normr) 139 %! assert (p, pn, s.normr)
141 %! assert (s.yf, y, s.normr) 140 %! assert (s.yf, y, s.normr)
142 %! assert (mu, [mean(x), std(x)]) 141 %! assert (mu, [mean(x), std(x)])
143 %! assert (s.normr/s2.normr < 1e-9) 142 %! assert (s.normr/s2.normr < sqrt(eps))
144 143
145 %!test 144 %!test
146 %! x = [1, 2, 3; 4, 5, 6]; 145 %! x = [1, 2, 3; 4, 5, 6];
147 %! y = [0, 0, 1; 1, 0, 0]; 146 %! y = [0, 0, 1; 1, 0, 0];
148 %! p = polyfit (x, y, 5); 147 %! p = polyfit (x, y, 5);