PAM INSTANTANEOUS SAMPLING clc ; clear ; close all; fm= input('enter the frequency of message signal'); t=-1:0.01:1; x=(t==0); y=sin(2*pi*fm*t); fs=100; N=length(t); xf=fftshift(fft(x,N)/N); f=linspace(-fs/2,fs/2,N); yf=fftshift(fft(y,N)/N); %part 1 subplot(2,2,1) plot(t,x) xlabel('Time') ylabel('Amplitude') title('Impluswe Function') grid on; subplot(2,2,2) plot( f, ceil(abs(xf))) xlabel('Frequency') ylabel('Amplitude') title('Frequency Response') grid on subplot(2,2,3) plot(t,y) xlabel('Frequency') ylabel('Amplitude') title('Sine Function') grid on subplot(2,2,4) plot(f,abs(yf)) xlabel('Frequency') ylabel('Amplitude') title('Frequency Response') grid on; %part 2 subplot(2,1,1) Fs=5*fm; t1=-1:1/Fs:1; y1=sin(2*pi*fm*t1); plot(t,y) xlabel('Time') ylabel('Amplitude') title('No Aliasing') hold on stem(t1,y1) grid on hold off subplot(2,1,2) Fs=1.5*fm; t1=-1:1/Fs:1; y1=sin(2*pi*fm*t1); plot(t,y) xlabel('Time') ylabel('Amplitude') title('Aliasing') hold on stem(t1,y1) grid on hold off
PAM INSTANTANEOUS SAMPLING clc ; clear ; close all; fm= input('enter the frequency of message signal'); t=-1:0.01:1; x=(t==0); y=sin(2*pi*fm*t); fs=100; N=length(t); xf=fftshift(fft(x,N)/N); f=linspace(-fs/2,fs/2,N); yf=fftshift(fft(y,N)/N); %part 1 subplot(2,2,1) plot(t,x) xlabel('Time') ylabel('Amplitude') title('Impluswe Function') grid on; subplot(2,2,2) plot( f, ceil(abs(xf))) xlabel('Frequency') ylabel('Amplitude') title('Frequency Response') grid on subplot(2,2,3) plot(t,y) xlabel('Frequency') ylabel('Amplitude') title('Sine Function') grid on subplot(2,2,4) plot(f,abs(yf)) xlabel('Frequency') ylabel('Amplitude') title('Frequency Response') grid on; %part 2 subplot(2,1,1) Fs=5*fm; t1=-1:1/Fs:1; y1=sin(2*pi*fm*t1); plot(t,y) xlabel('Time') ylabel('Amplitude') title('No Aliasing') hold on stem(t1,y1) grid on hold off subplot(2,1,2) Fs=1.5*fm; t1=-1:1/Fs:1; y1=sin(2*pi*fm*t1); plot(t,y) xlabel('Time') ylabel('Amplitude') title('Aliasing') hold on stem(t1,y1) grid on hold off