N = 2*1024;
dt = 10/(N-1);
t = 0:dt:10;
Ac = 2; m =1; fc = 5; fa = 0.4;

%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX AM Modulation XXXXXXXXXXXXXXXXXXXXXXX 
y=Ac*(1+m*sin(2*pi*fa*t)).*sin(2*pi*fc*t); % Equation of Amplitude
%modulated signal
plot(t,y);% Graphical representation of AM signal
title ('Amplitude Modulated signal');
xlabel ('time');
ylabel ('Amplitude');
grid on;

%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Frequency XXXXXXXXXXXXXXXXXXXXXXXXXXX
df = (1/dt);
fam = abs(fft(y));
fam = fam/N*2;
f = [0:N-1]/N*df;
K = 100;
k = 1:K;
bar(f(k),fam(k));
axis([0 maxfreq 0 4]);
grid on;
title ('AM frequency spectrum');
xlabel ('frequency Hz');
ylabel ('amplitude');
