0
$\begingroup$

If we multiply a Continuous-Time signal f(t) by a periodic pulse sequence we can get a sampled version of our signal. The problem I am having is that I am unsure how to create an impulse train in MATLAB that is sampled at fs intervals.

My Attempt at solution (code):

Ts = 1/8000
len = length(inputSignal)
impulseTrain = ones(1,len)
n = 0:Ts:Ts*(len-1)

What I need to do:

conv(inputSignal,impulseTrain)

Okay,so if I was to plot this result it would be very simple however, what I am required to do is convolve this impulse train with an input signal. I am unsure how to pass in the data. How do I get 23000 vectors of length 1 shifted by a distance Ts?

$\endgroup$
1
$\begingroup$

When you load a signal, it is already sampled. So continuous-time does not make much sense here. Creating an impulse train and convolving it cannot help you either. You should know the sampling rate of the signal you are going to load. Assume it is originally sampled at the rate $f_{s,\text{old}}$. This means the samples are apart in time by $1/f_{s,\text{old}}$ seconds.

Now you want to sample this signal with a sampling rate of $f_{s,\text{new}}$. That is, in the sampled signal you will have $1/f_{s,\text{new}}$ seconds time difference between every two consecutive samples. This problem is called resampling, or sampling rate conversion. There are different techniques to do so which you can learn in the given link or similar sources.

A quick approach to do it in Matlab is as follows:

old_fs = 11200; % or any other value it is
old_time_axis = (0:length(input_signal)-1)/old_fs;
new_fs = 8000; % new sampling rate
[p,q] = rat(new_fs/old_fs); %find the ratio of the sampling rates
resampled_signal = resample(input_signal,p,q);
new_time_axis = (0:length(resampled_signal)-1)/new_fs;

Notice that at sharp signal edges distortion can appear. You can minimize such effects, depending on your signal, by adjusting the resampling filter. Documentation can be found here.

$\endgroup$

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.