Advertisement
wieschoo

Untitled

Apr 30th, 2014
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.78 KB | None | 0 0
  1.  
  2. % Anzahl der Daten
  3. NumberOfData= 35;
  4. % Stützstellen zum Interpolieren
  5. SamplingPoints = linspace(-1,1,NumberOfData);
  6. %Runge-Funktion
  7. f = @(t) 1./(1+25.*t.*t);
  8. % Funktionswerte berechnen
  9. y = f(SamplingPoints);
  10.  
  11. % Punkte an denen später interpoliert werden soll
  12. TestPoints = SamplingPoints;
  13.  
  14. DivDif = zeros(NumberOfData,NumberOfData);
  15. DivDif(:,1) = y(:);
  16. for j=2:NumberOfData
  17.     for i=1:NumberOfData-j+1
  18.         DivDif(i,j) = (DivDif(i+1,j-1)-DivDif(i,j-1))/(SamplingPoints(i+j-1)-SamplingPoints(i));
  19.     end
  20. end
  21.  
  22. xt = ones(1,NumberOfData);
  23. yInterpol = DivDif(1,1);
  24. for j=1:NumberOfData-1
  25.     xt = xt.*(TestPoints-SamplingPoints(j));
  26.     yInterpol = yInterpol+DivDif(1,j+1).*xt;
  27. end
  28.  
  29.  
  30. % links
  31. plot(SamplingPoints,y,'r');
  32. hold on
  33. plot(SamplingPoints,yInterpol,'.k');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement