Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

polyfit()

299 views
Skip to first unread message

andra...@my-dejanews.com

unread,
Apr 21, 1999, 3:00:00 AM4/21/99
to
hi all

please excuse my ignorance, but so far i've been unable to identify a
scilab equivalent to matlab's polyfit() function.

i have a uni. assignment which requires me to fit a polynomial curve to a
small table of data; only matlab is supported by my academic staff.

tia

andy b.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Matthew Halfant

unread,
Apr 21, 1999, 3:00:00 AM4/21/99
to
function p = polyfit(x, y, n, s)
// return coefficient vector or poly if fourth string argument given
[lhs, rhs] = argn(0)
x = x(:); y = y(:)
m = length(x)
if length(y) <> m, error('x and y must have same length'), end
v = ones(m,n+1)
for i=2:n+1, v(:,i) = x.*v(:,i-1), end
p = (v\y)'
if rhs > 3, p = poly(p, s, 'coeff'), end
0 new messages