Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top