# Demodulating AM signal from carrier signal on Matlab

I'm trying to demodulate a voice signal (bandwidth approximately 5 kHz) from a carrier signal (100kHz).

h=10*sinc(10*(-10:10));

y1=filter(h,1,y);

But when I compare the signal with the "ground truth" signal provided, the size of the signal is 1/20th of the one I made. Did I miss some steps in the process? Thanks.

The reason of different signal lengths is due to their different sampling rates.

The original baseband analog audio signal $$m(t)$$ has a $$5$$ kHz bandwidth, and should be sampled at $$F_{bb} \geq 10$$ kHz, to represent it (without aliasing) in the discrete-time form $$m[n] = m(n / F_{bb})$$ in Matlab.

Assuming you want to use the lowpass sampling theorem, then the amplitude modulated analog signal $$x(t) = A_c m(t) \cos(2\pi f_c t + \phi)$$ has a carrier frequency of $$f_c = 100$$ kHz (its bandwidth is $$100+5$$ kHz) and has to be sampled by at least $$F_{am} = \frac{1}{T_{am}} = 210$$ kHz to represent it as $$x[n] = A_c m_{am}[n] \cos(2 \pi f_c n T_{am} + \phi)$$.

Note that in the latter case, the message signal $$m(t)$$ is oversampled into $$m_{am}[n]$$ by about $$F_{am}/F_{bb} = 210/10 = 21$$ for getting the sample by sample product. Hence the number of samples in the AM modulated (and demodulated) signal $$m_{am}[n]$$ which represents the audio information will be about $$21$$ times more than that of the original baseband audio representation in $$m[n]$$.

Typically you would downsample the demodulated audio sequence in order to reduce its sampling rate (and sample count).

Let's have a look at the concept of the AM modulation.

The simplest linear amplitude modulation formula (for DSB-SC) is:

$$m(t) = A(t) \cos(wt + \phi).$$

In amplitude modulation; you have a carrier signal that has a frequency that is fixed, $\phi$ function can be omitted, and a transmission signal which has it's information in $A(t)$ function. So we are basically modulating our signal to shape of the carrier.

There are different techniques for demodulation of AM modulated signals. The most basic method we can think about how to demodulate this signal is basically detecting the envelope of the signal. In real world, it is a matter of a diode and a well decided capacitor. In MATLAB, you have to simulate those characteristics.

There is an example of envelope detection here.

There is another way which is waaaay more easier to implement in MATLAB. The method is called "phase locked loop" (or something like that). Note that you can use this method IF your signal IS synchronous. The block diagram of this demodulation method is like this:

The most common mistake when applying analog demodulation techniques in MATLAB is sampling. You have to take your samples on the right frequency, and at the right points.

I hope this is a bit enlightening for you in the terms of amplitude modulation techniques. There is more of the demodulation methods, however who needs all of them anyway? Just take a look at them and find the method that fits for your needs. I used phase locked loop the most so if there is no specific needs, I suggest you to use it.

As always, Have a nice day.

• So after more research, this is the matlab code I came up with: %read in the audio [y,Fs]=audioread('Signal1.wav'); [gt,fs]=audioread('Signal1_gt.wav'); %demodulate the audio x=sin(pi); y=y*x; %low pass filter h=10*sinc(10*(-10:10)); y1=filter(h,1,y); %down sample y1=downsample(y1,Fs/fs); But when I try to plot it out, the y1 signal is much more smaller than gt signal in term of magnitute. What you reckon the problem is? – Anh Tran Oct 17 '17 at 12:34
• It's not a problem at all. You will be still able to hear all the voice clearly. However, this generally happens due to filtering. Since you are basically multiplying your signal while filtering, low filter responses can occur as the lower magnitude signal. – Furkan Küçük Oct 18 '17 at 7:43