% Sinc function weighting example steps through points of a sampled % rectangular pulse to interpolate points between existing points (based % on a higher sampling frequency). This demonstrates sinc weighting on % neighboring points to interpolate points between existing points. % In the graphics of this script notice the intersection of the sinc % with all the other existing samples, resulting in a weighted % contribution to the interpolated point. % % written by Kevin D. Donohue (donohue@engr.uky.edu) June 2002 % Create discrete time axis for sampling signal fs =5; t = [-3*fs:3*fs]/fs; % Generate rectangular pulse sig = rectpuls(t,1); % With width of 2 seconds centered on 0. % Create more densely sampled time axis for sinc function interpolator fsc = fs*10; % Increase sampling rate by factor of 10 tc = [-3*fsc:3*fsc]/fsc; % Loop to slide sinc function along axis one FSC sample at a time % start just before middled of signal at t =0; for k = fix(length(tc)/2):fix(length(tc)/2)+11 stem(t,sig) % Plot stem plot of original signal at sample points hold on s = sinc((tc-tc(k))*fs); % Supperimpose sinc shifted by a submultiple of sampling increment plot(tc,s,'r', [tc(k) tc(k)], [0 1], 'g--') % Draw a green vertical line at interpolation point xlabel('Seconds') ylabel('Amplitude') title('Sinc function weights on surrounding points to interpolate at green broken line') axis([-1, 1, -.5, 1.1]) % Limit axis around t=0 to get a better look hold off disp('Hit any key to continue') pause end