Advertisement
Guest User

Metnum3

a guest
Apr 5th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.46 KB | None | 0 0
  1. close()
  2. clear
  3. clc
  4.  
  5. x=[6 8 16 49];
  6. y=[2.5 11.35 31.01 49.9];
  7.  
  8. n=length(x);
  9.  
  10. A=[n sum(x) sum(x^2) sum(x^3); sum(x) sum(x^2) sum(x^3) sum(x^4);sum(x^2) sum(x^3) sum(x^4) sum(x^5); sum(x^3) sum(x^4)sum(x^5) sum(x^6)];
  11. Y1=[sum(y); sum(y.*x); sum(y.*x^2); sum(y.*x^3)];
  12.  
  13. P=inv(A)*Y1
  14. for i=1:n
  15.     mprintf(" p%i= %f ",i,P(i))
  16. end
  17.  
  18. z=0:0.01:50;
  19. deff('[yk]=fun1(z)','yk=P(1)+P(2)*z+P(3)*z^2+P(4)*z^3')
  20.  
  21. plot(z,fun1(z),x,y,'o')
  22. xlabel('x')
  23. ylabel('y(x)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement