Mercurial > octave-nkf
comparison scripts/polynomial/polyfit.m @ 7411:83a8781b529d
[project @ 2008-01-22 21:52:25 by jwe]
author | jwe |
---|---|
date | Tue, 22 Jan 2008 21:52:26 +0000 |
parents | a1dbe9d80eee |
children | 2df882e69f13 |
comparison
equal
deleted
inserted
replaced
7410:8a3b2ccc4e11 | 7411:83a8781b529d |
---|---|
102 ## Return value should be a row vector. | 102 ## Return value should be a row vector. |
103 | 103 |
104 p = p.'; | 104 p = p.'; |
105 | 105 |
106 endfunction | 106 endfunction |
107 | |
108 %!test | |
109 %! x = [-2, -1, 0, 1, 2]; | |
110 %! assert(all (all (abs (polyfit (x, x.^2+x+1, 2) - [1, 1, 1]) < sqrt (eps)))); | |
111 | |
112 %!test | |
113 %! x = [-2, -1, 0, 1, 2]; | |
114 %! assert(all (all (abs (polyfit (x, x.^2+x+1, 3) - [0, 1, 1, 1]) < sqrt (eps)))); | |
115 | |
116 %!error polyfit ([1, 2; 3, 4], [1, 2; 3, 4], 4); | |
117 | |
118 %!test | |
119 %! x = [-2, -1, 0, 1, 2]; | |
120 %! fail("polyfit (x, x.^2+x+1)"); | |
121 | |
122 %!test | |
123 %! x = [-2, -1, 0, 1, 2]; | |
124 %! fail("polyfit (x, x.^2+x+1, [])"); | |
125 |