SHARE
TWEET

Untitled

a guest Nov 15th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clear;
  2. clc;
  3.  
  4.  
  5. n=5;
  6. X=[-1.32; -0.84; -0.41 ; 0.16; 0.33; 1.09];
  7. Y=[-2.12; -2.09; 1.07; 0.51; -0.27; 1.51];
  8. x_bar=0.25;
  9.  
  10.  
  11.  
  12. function y=W(x, n, X, Y)
  13.     for j=0:n
  14.         S(j+1)=Y(j+1)*phi(j,x,X,n);
  15.     end;
  16.     y=sum(S);
  17. endfunction;
  18.  
  19. function y=omega(x,n,X);
  20.     y=1;
  21.     for i=0:n
  22.         y=y*(x-X(i+1));
  23.     end;
  24. endfunction;
  25.  
  26. D=zeros(n+1,n+1);
  27. D(:,1)=Y;
  28.  
  29. for k=1:n
  30.         for i=0:(n-k)
  31.             D(i+1,k+1)=(D(i+2,k)-D(i+1,k))/(X(i+k+1)-X(i+1));
  32.         end;
  33. end;
  34.  
  35. Tmp(i+1)=D(1,1);
  36.  
  37. for i=1:k
  38.         Tmp(i+1)=D(1,i+1)*omega(x_bar,i-1,X);
  39. end;
  40.     Wn=sum(Tmp);
  41.  
  42.  
  43.  
  44.  
  45. disp(Wn,"Wn=");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top