I want the plot of convolution b/w f1 and f2 in the below program.. f1 and f2 are the Fourier transform of Gate func and Train of impulse

2 views (last 30 days)
fSampling = 10000;
tSampling = 1/fSampling;
L = 10000;
to = (0:L-1)*tSampling;
F = 100;
t = -5:0.01:5;
w=1;
a= rectpuls(t,2);
subplot(2,4,1);
plot(t,a);
xlabel('Time');
ylabel('Amplitude');
title('Message signal');
grid on;
% Fourier transform of sine wave
subplot(2,4,2)
NFFT = 2^nextpow2(L);
Xsig = fft(a,NFFT)/L;
f1 = fSampling/2*(linspace(0,1,NFFT/2+1));
plot(f1,2*abs(Xsig(1:NFFT/2+1)),'r');
grid on;
axis([-50 500 1.0000e-005 1])
title('\itSignle-Sided Amplitude Sepectrum of Gate Function ');
xlabel('\itFrequency(Hz) \rightarrow');
ylabel('|Xsig(f)| \rightarrow');
% train of impulse
n= -5:1:5;
l =length(n);
for i= 1:l
x(i)=1;
end;
subplot(2,4,3);
stem(n,x);
xlabel('Time');
ylabel('Amplitude');
title('Train of Impulses');
grid on;
% Fourier Transform of Train of Impulse
subplot(2,4,4);
NFFT = 2^nextpow2(L);
Xsig = fft(x,NFFT)/L;
f2 = fSampling/2*(linspace(0,1,NFFT/2+1));
stem(f2,2*abs(Xsig(1:NFFT/2+1)),'r');
grid on;
axis([-50 500 1.0000e-005 1])
title('\itSignle-Sided Amplitude Sepectrum of Train of impulse ');
xlabel('\itFrequency(Hz) \rightarrow');
ylabel('|Xsig(f)| \rightarrow');
% multiplication of signals
T = -5:0.01:5;
b = a.*x(i);
subplot(2,4,5);
stem(T,b);
xlabel('Time');
ylabel('Amplitude');
title('Sampled signal');
grid on;
% Fourier transform of Sampled Signal
subplot(2,4,6); NFFT = 2^nextpow2(L);
Xsig = fft(x,NFFT)/L;
f3 = fSampling/2*(linspace(0,1,NFFT/2+1));
plot(f3,2*abs(Xsig(1:NFFT/2+1)),'r');
grid on;
axis([-50 500 1.0000e-005 1])
title('\itSignle-Sided Amplitude Sepectrum of Sampled Signal ');
xlabel('\itFrequency(Hz) \rightarrow');
ylabel('|Xsig(f)| \rightarrow');
%Convolution of f1 and f2
c= conv(f1,f2);
subplot(2,4,7);
plot(c);
grid on;
  3 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!