Advertisement
Guest User

Untitled

a guest
Aug 10th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.77 KB | None | 0 0
  1. t=linspace(-.5,.5,256);
  2. x=exp(-pi*t.^2*16).*(sin(2*pi*40*t)+0.154*cos(2*pi*47*t)-1.454*cos(2*pi*27*t));
  3. figure;plot(t,x)
  4.  
  5. tt=linspace(-.5,.5,256*8-7);
  6. xorj=exp(-pi*tt.^2*16).*(sin(2*pi*40*tt)+0.154*cos(2*pi*47*tt)-1.454*cos(2*pi*27*tt));
  7. figure;plot(tt,xorj)
  8.  
  9. xf=SincInt(x,8,1);
  10. sh=0;
  11. xf=[ xf(1+sh:end) zeros(1,sh)];
  12. figure;plot(tt,xf)
  13. hold on;plot(tt,xorj)
  14. figure;plot(tf,xf-xorj)
  15.  
  16. function f = SincInt( f,k ,varargin)
  17. % function f = SincInt( f,k ,varargin)
  18. % varargin=1 to keep the beginning and the end the same
  19.  
  20. nargin=length(varargin);
  21.  
  22. N=length(f);
  23. f=[zeros(1,N*(k-1)) f];
  24. for  i = 1: N
  25.     f(k*i-k+1:k*i)= [zeros(1,k-1) f(N*(k-1)+i)];
  26. end
  27.  
  28. f=conv(f,sinc(-60:1/k:60),'same');
  29.  
  30. if(nargin==1 && varargin{1})
  31.     f=[f(k:length(f)) ];
  32. end
  33.  
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement