daily pastebin goal
6%
SHARE
TWEET

Untitled

a guest Aug 12th, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Esercizio24(f,a,b,N)
  2.  
  3.     %cambio intervallo
  4.     tk = linspace(a,b,N+1)';
  5.     tk(end) = [];
  6.     yk = f(tk);
  7.  
  8.     grado = N-1;
  9.     k = 0:grado;
  10.     xk = 2*pi/(b-a)*(tk-a);
  11.  
  12.     A = exp(i*xk*k);
  13.     %risoluzione del sistema e calcolo dei coefficienti
  14.     c1 = A\yk;
  15.     c2 = (A/N)*yk;
  16.     c3 = fft(yk)/N;
  17.     c = [c1 c2 c3];
  18.    
  19.     %coordinate della funzione data
  20.     t = linspace(a,b,200);
  21.     y = f(t);
  22.     x = 2*pi/(b-a)*(t-a);
  23.  
  24.     for j = 1:length(c)
  25.         subplot(3,1,j);
  26.         Q = polyval(flipud(c(:,j)),exp(i*x));
  27.         h = plot(t,y,t,real(Q),'g',tk,yk,'or');
  28.         set(h,'LineWidth',2,'MarkerFaceColor','r');
  29.         title(['Funzione : ' char(f) ' Punti :' int2str(N)]);
  30.         legend('grafico funzione data','polinomio trigonometrico interpolante',...
  31.                'dati interpolazione');
  32.     end  
  33. end
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