Advertisement
encoree1996

polyfit

Apr 27th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.27 KB | None | 0 0
  1. function [ wsp ] = aproksymacja(x,y,m)
  2. G = zeros(m+1,m+1);
  3. n = size(x);
  4. for i=0:m
  5.     for j=0:m
  6.         G(i+1,j+1) = sum(power(x,i+j));
  7.     end
  8. end
  9. b = zeros(m+1,1);
  10. for k=0:m
  11.     b(k+1) = sum(times(power(x,k),y));
  12. end
  13.  
  14. a = G\b;
  15. a=a';
  16. wsp=fliplr(a);
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement