0
\$\begingroup\$

I have a sinusoidal signal x(t) sampled with period 1/fs. The result is the discrete signal x[n], where x[n]=x(t)|t=nT. Then I perform an upsampling of factor, let's say, 8 to increase the sampling frequency by a factor of 8. Here's the code in matlab syntax:

f=10e6; % signal's frequency
fs=1e9; % sampling frequency
t=0:1/fs:20/f1-1/fs; % time vector
x=sin(2*pi*f*t); % sinusoidal signal

% upsampling by a factor of 8
x1=upsample(x,8);
% filtering
filt=[1,2,1,2,1,2,1,2,1]/2; %triangular impulse response
foh=conv(x1,filt,'same');

%scale time axis
nt=0:1/(8*fs):20/f-1/(8*fs); % scaled time vector

%plot reconstructed signal
plot(nt,foh)

Now after running the above code I get the following plot as the output of the reconstructed signal, which doesn't appear to be a sinusoidal anymore,

enter image description here

This more looks like a predictive first-order hold than a basic one. There seems to be something wrong with my filtering scheme but don't know how to fix that to get a basic FOH response.

Thanks..

\$\endgroup\$
1
\$\begingroup\$

Your filt is simply not a first-order hold filter.

Fix that by writing down what each sample in your 7 inter-original-sample samples need to have as value. You'll come up with a description like:

The first inserted sample needs to be the sum of the last sample, and the 1/8 of the difference to the next input sample.

That is a simple linear equation:

\begin{align} y[n=m+1] &= x[m] + (x[m+8]-x[m])\cdot\frac 18\\ &= x[n-1] + \frac18 x[n+7] + (-\frac18)x[n-1]\\ &= \frac{8-1}8 x[n-1] + \frac18 x[n+7] \end{align}

notice where the the $1$ from the index on the left side reappears on the right side.

Do the same for the second, third, … seventh sample that you insert.

You'll notice that the vector you get bears no resemblance to your filt coefficients!

\$\endgroup\$
  • \$\begingroup\$ I actually want to correct the filter filt and do the convolution with x[n] to reconstruct the signal. What you'e suggesting is ok but not like what I asked \$\endgroup\$ – dirac16 May 19 at 19:52
  • \$\begingroup\$ Please try to do what I recommend in my answer: compare your convolution with the vector filt with the coefficients you get by doing above considerations for the interpolated values. My answer addresses exactly what you address in your comment! \$\endgroup\$ – Marcus Müller May 19 at 20:01
  • \$\begingroup\$ I have to insert 7 zeros after each sample. There are say N samples. So should I write down y[n] for 7N samples? The other thing I don't get from your answer is as to how the data vector y[n] would lead to the coefficients of filt. Also what does index m indicate? Sorry I'm new to signal processing.. Still have got a lot to learn \$\endgroup\$ – dirac16 May 19 at 20:34
  • \$\begingroup\$ yes, write down that y for the seven interpolated samples :) Then, write down what the convolution with filt means, i.e. imagine your filter would consists of a coefficient series h[n], and simply write down what, for example, y[n] would look like for n=m+4 (with that I meant "the fourth inserted sample"). \$\endgroup\$ – Marcus Müller May 20 at 5:15

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.