# AM demodulation using MATLAB

Started by August 19, 2006
```Hey all,
I am having some trouble with AM demodulation using MATLAB. I used the
built-in MATLAB function butter to design a low pass filter and using
the transfer function obtained, I filtered the modulated signal
multiplied by the carrier. Here's the part of my m-file which deals
with it:

dam=cos(2*pi*250*t).*am; % am=amplitude modulated signal
[b,a]=butter(5,250*2*Ts); %designing low pass filter with corner freq
250Hz, Ts-sampling      %interval
dam(:,1) = filtfilt(b,a,dam(:,1)); % filtering the demodulated signal
dam=dam*2; %scaling to get original amplitude back

the problem is that I'm trying to filter the signal without using the
built in matlab functionality. I tried to multiply the transfer
function of filter with the fourier transfer of dam (fft(dam)) to low
pass filter it and then took the inverse fft of the answer, but came up
with a weird answer when i tried to plot the demodulated signal.

could someone tell me what i'm doing wrong when i am trying to filter
it? Is there any other way around this without using built-in matlab
functions? Thanks a lot in advance. -Farah.

```
```<farah727rash@gmail.com> wrote in message
> Hey all,
> I am having some trouble with AM demodulation using MATLAB. I used the
> built-in MATLAB function butter to design a low pass filter and using
> the transfer function obtained, I filtered the modulated signal
> multiplied by the carrier. Here's the part of my m-file which deals
> with it:
>
> dam=cos(2*pi*250*t).*am; % am=amplitude modulated signal
> [b,a]=butter(5,250*2*Ts); %designing low pass filter with corner freq
> 250Hz, Ts-sampling      %interval
> dam(:,1) = filtfilt(b,a,dam(:,1)); % filtering the demodulated signal
> dam=dam*2; %scaling to get original amplitude back
>
>
> the problem is that I'm trying to filter the signal without using the
> built in matlab functionality. I tried to multiply the transfer
> function of filter with the fourier transfer of dam (fft(dam)) to low
> pass filter it and then took the inverse fft of the answer, but came up
> with a weird answer when i tried to plot the demodulated signal.
>
> could someone tell me what i'm doing wrong when i am trying to filter
> it? Is there any other way around this without using built-in matlab
> functions? Thanks a lot in advance. -Farah.
>

There are two ways to demodulate AM. One way is to full wave(or half wave)
rectify and then filter and the second method is to recover the carrier with
a PLL and multiply this back into the AM - then filter.(synchronous
demodulation). Which are you doing? There is another way of course using I
and Q for software radio - sqrt(I^2+Q^2).

M.P

--
Posted via a free Usenet account from http://www.teranews.com

```
```"farah727rash@gmail.com" <farah727rash@gmail.com> wrote in

> the problem is that I'm trying to filter the signal without using the
> built in matlab functionality. I tried to multiply the transfer
> function of filter with the fourier transfer of dam (fft(dam)) to low
> pass filter it and then took the inverse fft of the answer, but came up
> with a weird answer when i tried to plot the demodulated signal.
>
>

If I know Matlab, this might be due to the inverse fft having complex parts
due to small numeric error.  If the output of your inverse fft is complex,
take the real part before plotting it.

--
Scott