% Signal parameters

Fc = 1475; 

Fm = 200; 

m = 0.05;



% Sampling parameters

Fs = 5000; 

Nsamples = 100;

n = 0:Nsamples-1;



% Sample

x = (1+m*cos(2*pi*Fm/Fs*n)).*cos(2*pi*Fc/Fs*n);



% DFT

Nfft = Nsamples;

k = 0:Nfft-1;

k = k-floor(length(k)/2); % To match the results of 'fftshift'

fk = Fs*k/Nfft;

X = abs(fft(x,Nfft)/Nsamples);

X = fftshift(X);



% Display results

subplot(211);

stem(n,x);

xlabel('n'); ylabel('x[n]');

tTitle = sprintf('Fc=%d, Fm=%d, m=%.2f',Fc,Fm,m);

title(tTitle);



subplot(212);

plot(fk,X,'.-');

xlabel('F_k (Hz)');

ylabel('|X(F_k)|');

tTxt = sprintf('Nfft=%d',Nfft);

title(tTxt);