fs=1000; % oversampling freq. for generating signal waveform
ts=1/fs; % oversmaping period
Fs=100; % sampling freq
Ts=1/Fs; % sampling time
OVR=fs/Fs; % oversampling ratio
T=1; % obervation time
fm1=40; % freq. of signal #1
fm2=60; % freq. of signal #2
tx=0:Ts:T-Ts; % time axis of the observation period
Nfft=length(tx); % length of N-point FFT
%---------------------------------------------------------
% Signal Generation and Find Its Spectrum -------------
x1c=cos(2*pi*fm1*(0:ts:T-ts)); % signal waveform #1
x2c=cos(2*pi*fm2*(0:ts:T-ts)); % signal waveform #2
x1=cos(2*pi*fm1*tx);
x2=cos(2*pi*fm2*tx);
X1=fftshift(fft(x1,Nfft));
X2=fftshift(fft(x2,Nfft));
fx=-Fs/2:Fs/Nfft:Fs/2-Fs/Nfft; % freq. axis
%--------------------------------------------------------
% Plot Figures ---------------------------------------
%%% (a) Transmitted Signal # 1 and Its Spectrum
figure(1);
subplot(211);
plot(0:ts:T-ts,x1c);
hold on;
stem(tx,x1,'ro');
hold off;
legend('x1c', 'x1');
axis([0 0.2 1.2*min(x1c) 1.2*max(x1c)]);
title(['Signal and Its Samples, with Message freq. fm=' num2str(fm1)...
' Hz, Sampling freq. Fs=' num2str(Fs) ' Hz']);
Nfft=length(tx); % length of N-point FFT
%---------------------------------------------------------