0
$\begingroup$

I am trying to formulate an algorithm for applying to Shannon interpolation formula to the discrete signal

$$x[n]=\frac{c^2}{4}\int\limits_{0}^{n T}y\left(\tfrac{c}{2}s\right)\,ds,$$

where $c$ is constant. Now, if $\frac{1}{T}=f_{s}>2B$, where $B$ is the band-limit of $X(f)$, then we can reconstruct the continuous time signal as:

$$x_{\text{const}}(t)=\sum\limits_{n=-\infty}^{\infty}\frac{c^2}{4}{\int\limits_{0}^{n T}y\left(\tfrac{c}{2}s\right)\,ds}\cdot\text{sinc}\left(\frac{t-n T}{T}\right)$$

function x=interpolate(y,N,T,c)
     x=0;
     for n=1:N
         x=x+((c^2)/2)*integral(y,0,n.*T).*sinc((t-n.*T)./T);
     end

However, I am having trouble with incorporating the t variable here. Setting it as global and running interpolate(y,20,20,1) also produces nothing to note.

Note that the continuous time signal in question is given by

$$x_{\text{true}}(t)=\frac{c^2}{4}\int_{0}^{t}y\left(\tfrac{c}{2}s\right)\,ds.$$

$\endgroup$
  • $\begingroup$ Can you give a reference, where you have these equations from? To me, Shannon interpolation is simply sampling the original signal without an integral. Further, I believe your integral should run from $\int_{(n-1)T}^{nT}ds$ and I have no idea, what the variable $c$ should define (I would always assume $c=2$ looking at these equations). $\endgroup$ – Maximilian Matthé Feb 7 '17 at 18:53
  • $\begingroup$ @MaximilianMatthé See this article here: en.wikipedia.org/wiki/… Also, $c$ is a constant, although I thought it'd be interesting to experiment whether I could vary it. However, yes, I also went with $c=2$ for graph plotting, etc. $\endgroup$ – Jason Born Feb 7 '17 at 18:55
  • $\begingroup$ Well, actually in this Wikipedia article, I cant find the integral you are stating there. $\endgroup$ – Maximilian Matthé Feb 7 '17 at 19:20
  • $\begingroup$ @MaximilianMatthé I apologise, the integral is due to the fact that the continuous time signal is given by $$x(t):=\frac{c^2}{4}\int_{0}^{t}y\left(\frac{cs}{2}\right)\,ds,$$ which we can sample to get $x[n]$. $\endgroup$ – Jason Born Feb 7 '17 at 20:11
3
$\begingroup$

Given your samples $x[n]$, here's a code to perform the interpolation by the sinc-functions:

F = 1000; % the sampling frequency used for drawing the continuous function
Fs = 50; % the sampling frequency
T = 1/Fs; % the sampling time

t = 0:1/F:1; % the time-samples for "continuous" plotting
ts = 0:T:1;  % the time at the sample points

% the original function. In your case, this would be integral expression
x = @(t) sin(2*pi*10*t) + cos(2*pi*11*t); 
xn = x(ts);  % the discrete sequence 

% perform interpolation from xn to x:
interpolated = 0;
for n=1:length(ts)
    % n-1 due to the 1-based indexing of matlab
    interpolated = interpolated + xn(n) * sinc((t-(n-1)*T)/T);
end

hold off;
plot(t, x(t), 'r', 'linewidth', 3); hold on;  % plot continuous
stem(ts, xn);  hold on; % plot sampled
plot(t, interpolated, 'k-o'); % plot interpolated on top of red curve

enter image description here

As a bonus, here's what happens when the signal is not enough bandlimited: I changed the frequency of the first sine from $sin(2\pi 10 t)$ to $sin(2\pi 30 t)$: enter image description here

Note: The Shannon-Interpolation requires bandlimited signals, so in particular it does not work exactly with time-limeted signals (since these are never band-limited). So, you will see some deviations especially at the edge of the signal.

$\endgroup$
  • $\begingroup$ it's a lotta work for a sorta parochial problem (i dunno what the integral was doing in there either). $\endgroup$ – robert bristow-johnson Feb 8 '17 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.