% Synch AM
clear

vdc=0;

fc=40000;
fm=1000;
t=[0:999]*0.005/1000;

v1=sin(2*pi*fc*t);
v2=sin(2*pi*fm*t);
v25=v2+vdc;
v3=v1.*v25;

subplot(2,3,1);
plot(t,v3);title('AM Waveform');xlabel('Time (sec)');
ylabel('Amplitude (V)');

v4=v3.*v1;
subplot(2,3,2);
plot(t,v4);title('Multiplication Result - Time Domain');
xlabel('Time (sec)');ylabel('Amplitude (V)');

V4=fft(v4);
subplot(2,3,3);
plot(t(1:500)*40*10^6,abs(V4(1:500)));
title('Multiplication Result - Frequency Domain');
xlabel('Frequency (Hz)');

[b,a]=butter(10,0.1);
v5=filter(b,a,v4);
subplot(2,3,4);
plot(t,v5);title('Demodulated Signal - Time Domain');
xlabel('Time (sec)');ylabel('Amplitude (V)');

V5=fft(v5);
subplot(2,3,5);
plot(t(1:500)*40*10^6,abs(V5(1:500)));
title('Demodulated Signal - Frequency Domain');
xlabel('Frequency (Hz)');


