plot the abs of fft.
fb=1000; %frecuency of the square signal
Tb=1/fb;
fs = 999/Tb;
%t=0:Tb/999:7*Tb; %time vector
t=0:1/fs:7*Tb; %time vector
fc=100; %frecuency of the carrier
A=1; %amplitude of the signal
cosine = A.*cos(2*pi*fc*t); %carrier
subplot(4,1,1)
plot(t,cosine)
xlabel('Time')
ylabel('Amplitude')
title('Carrier')
m_t = A/2.*square(2*pi*fb*t)+(A/2);%Binary signal
subplot(4,1,2)
plot(t,m_t)
xlabel('Time')
ylabel('Amplitude')
title('Pulsos binarios')
s_t = cosine.*m_t; % ASK signal
subplot(4,1,3)
plot(t,s_t)
xlabel('Time')
ylabel('Amplitude')
title('ASK')
N=length(m_t);
f =(0:N-1)*(fb/N);
fftASK=fft(s_t);%Fourier ASK signal
subplot(4,1,4)
plot(f,abs(fftASK))
xlabel('frequency')
ylabel('ASK amplitude')
title('fft ASK')
figure(2)
n = length(fftASK);
plot((0:n-1)/n*fs, abs(fftASK));
xlabel('f (Hz)');
ylabel('Amp')