A program to generate an amplitude modulated wave with modulated frequency 5000HZ and carriar frequency 1080000HZ and study of its characteristics

fm=5000;
fc=1080000;
time=0:2.3148e-7:8e-4;
amp=1;
ac=2;
k=amp/ac;

modwave=amp*cos(2*pi*fm*time);
figure(1);
plot(time,modwave);
title(' Waveform of modulating signal');
xlabel('Time (sec)');
ylabel('Amplitude');
grid on;

carwave=ac*cos(2*pi*fc*time);
figure(2);
plot(time(1:500),carwave(1:500));
title(' Waveform of carrier signal');
xlabel('Time (sec)');
ylabel('Amplitude');
grid on;

figure(3);
mt=k*cos(2*pi*fm*time);
sam=ac*(1+mt).*cos(2*pi*fc*time);
plot(time(1:1500),sam(1:1500));
title(' Waveform of modulated signal');
xlabel('Time (sec)');
ylabel('Amplitude');
grid on;

n=length(time);
figure(4)   
spectrum=abs(fftshift(fft(modwave,n)))/n;   
 fw=-2160000:1250:2160000;   
plot(fw(1152:2304),spectrum(1152:2304))   
title('Frequency Domain analysis of modulating wave')   
xlabel('Frequency (Hz)')   
ylabel('Magnitude')

figure(5)   
spectrum1=abs(fftshift(fft(carwave,n)))/n;   
 fw=-2160000:1250:2160000;
plot(fw,spectrum1)   
title('Frequency Domain analysis of carrier wave')   
xlabel('Frequency (Hz)')   
ylabel('Magnitude')

figure(6)   
spectrum2=abs(fftshift(fft(sam,n)))/n;   
 fw=-2160000:1250:2160000;
plot(fw,spectrum2)   
title('Frequency Domain analysis of modulated wave')   
xlabel('Frequency (Hz)')   
ylabel('Magnitude')