SHARE
TWEET

Untitled

a guest Dec 8th, 2019 276 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function [ approx ] = interpol( a, points, origin, K )
  2.     approx = 0;
  3.     for i = 1 : K
  4.         center = points(:,i);
  5.         r = norm (origin - center);
  6.         approx = approx + a(i) * phigauss(r);
  7.     end
  8. end
  9.  
  10. function [ output_args ] = phigauss( r )
  11.     b = 0.653;
  12.     output_args = exp (-1*(b*r)^2);
  13. end
  14.  
  15.  
  16.  
  17. load('dataset0.mat')
  18.  
  19. K = Nt;
  20. points = [ xt'; yt' ];
  21.  
  22. %calculate phi matrix
  23. phiVector = zeros(Nt,Nt);
  24. for i = 1 : Nt
  25.    origin = points(:,i);
  26.    for j = 1 : Nt
  27.       center = points(:,j);
  28.       r = norm (origin - center);
  29.       phiVector(i,j) = phigauss(r);
  30.    end
  31. end
  32.  
  33. %calcualte a
  34. phiVector = triu(phiVector);
  35. a = phiVector^-1 * ft;
  36.  
  37. %calculate approximation
  38. %{
  39. approx = zeros(Nt,1);
  40. for i = 1 : Nt
  41.    origin = points(:,i);
  42.    approx(i) = interpol(a, points, origin, K);
  43. end
  44. %}
  45.  
  46. emean = 0;
  47. pointsV = [ xv'; yv' ];
  48. approx = zeros(Nv,1);
  49. for i = 1 : Nv
  50.    origin = pointsV(:,i);
  51.    approx(i) = interpol(a, points, origin, K);
  52.    emean = emean + norm(fv(i) - approx(i));
  53. end
  54.  
  55. emean = emean / Nv;
  56. %error
  57.  
  58.  
  59.  
  60. %plot
  61. %{
  62. tri = delaunay(xt,yt);
  63. trisurf(tri,xt,yt,approx)
  64. shading interp
  65. %}
  66. tri = delaunay(xv,yv);
  67. trisurf(tri,xv,yv,approx)
  68. shading interp
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
 
Top