0

I am using the following code for modulating and demodulating a simple waveform.

Fs = 44100;
T = 1;
Fc = 15000;
t=[0:1/Fs:T];
x=cos(20*pi*t);
y=ammod(x,Fc,Fs);
z=amdemod(y,Fc,Fs);
plot(z);

When Fc is around 12k, 'z' is same as 'x' but when Fc is high (around 15k, like in code above), 'z' is not proper. Although the waveform looks similar to 'x', it is like a modulated wave. I am clearly missing something ( I know that Fs > 2*(Fc+BW) and I guess I am following it right in the above code) Can any please help?

BaluRaman
  • 265
  • 5
  • 16

1 Answers1

2

Have a look at the spectrum of you demodulated signal: enter image description here

You need to low-pass filter the signal. You can use the following:

% Parameters
Fs = 44100;
T  = 1;
Fc = 15000;
Fm = 10;

% Low-pass filter design
[num,den] = butter(10,1.2*Fc/Fs); 

% Signals
t = 0:1/Fs:T;
x = cos(2*pi*Fm*t);
y = ammod(x,Fc,Fs);
z = amdemod(y,Fc,Fs);
w = amdemod(y,Fc,Fs,0,0,num,den); 

% Plot
figure('Name','AM Modulation');
subplot(4,1,1); plot(t,x); title('Modulating signal');
subplot(4,1,2); plot(t,y); title('Modulated signal');
subplot(4,1,3); plot(t,z); title('Demodulated signal');
subplot(4,1,4); plot(t,w); title('Demodulated signal (filtered)');

The results is:

enter image description here

tashuhka
  • 5,028
  • 4
  • 45
  • 64
  • The documentation says that amdemod demodulates the signal. Doesnt it mean that it is already being passed through low-pass filter? – BaluRaman Feb 20 '14 at 09:16
  • Indeed, the ´amdemod´ function is doing some low-pass filtering by default. However, it seems that it is not good enough... – tashuhka Feb 20 '14 at 09:25
  • In your low-pass filter, you are using 'Fm'. Could you please design a filter without it? I tried the following code but its not working [b,a] = butter(2,Fc/(Fs/2),'low'); y = filter(b,a,z); I am not sure what value to give for the normalized frequency – BaluRaman Feb 20 '14 at 09:31
  • I have updated the code, so that you can include the filter parameters in the function `amdemod` itself without the _Fm_ value. – tashuhka Feb 20 '14 at 09:33