Page 1 of 1

PROBLEM 6 (10pts) in the class Let's set the filter_simulation.m code that we covered. (N=2001, T=2, td=200*dT, wd=W/30)

Posted: Thu May 05, 2022 1:12 pm
by answerhappygod
Problem 6 10pts In The Class Let S Set The Filter Simulation M Code That We Covered N 2001 T 2 Td 200 Dt Wd W 30 1
Problem 6 10pts In The Class Let S Set The Filter Simulation M Code That We Covered N 2001 T 2 Td 200 Dt Wd W 30 1 (62.23 KiB) Viewed 22 times
I would like to know the solution and answer to the problems
above using the matlab code below.
%% sound signal Fourier Transform
% Filtering experiment
clear all;
clc;
close all;
% time domain axis
N=2001; % number of samples
T=2; % Time domain size
dT=T/N; % time sampling interval
W=2*pi/dT; % Angular frequency domain size
dW=W/N; % angualr frequency sampling interval
Ta=0:dT:T-dT; % sample time point grid : center value
sampling
Wa=-W/2 +dW/2 : dW : W/2 -dW/2;
%
% figure(504);
% plot(Ta,cos(Wa((N+1)/2+4)*Ta)); %
td=200*dT; % time-delay
% low-pass filter in frequency domain
wd=W/30 ; % rectangular function width
rectF=zeros(N,1);
for k=1:N

if abs(Wa(k)) < wd/2
rectF(k)=1*exp(-1i*td*Wa(k));
end

end
FtR=(1/(2*pi))*(N)*ifft(fftshift(rectF))*dW; % Inverse FT:
frequency->time
figure(3);
subplot(1,2,1); plot(Wa,abs(rectF)); title(' H(jw)');
xlabel('w-axis');
subplot(1,2,2); plot(Ta,abs(FtR)); title(' h(t)');
xlabel('t-axis');
set(gca,'fontsize',16);
% truncated low-pass filter
tFtR=zeros(N,1);
for k=1:N

if abs(Ta(k)-td)<td

tFtR(k)=real(FtR(k)); % real number
end
end
trectF=ifftshift(fft(tFtR))*dT; % Forward FT:
time->frequency
ht = tFtR(td/dT-td/dT+1:td/dT+td/dT); % impulse response
figure(4);
subplot(1,2,1); plot(Wa,abs(trectF)); title(' H(jw)');
xlabel('w-axis');
subplot(1,2,2); plot(Ta,abs(tFtR)); title(' h(t)');
xlabel('t-axis');
set(gca,'fontsize',16);
%% convolution integral: y(t)=h(t)*x(t) =
intetal(0-t)x(tau)*h(t-tau)*dtau
ws=Wa( (N+1)/2 +60 ); %
f_signal1=cos(ws*Ta); %
x=f_signal1';
y=zeros(N,1);
figure(54);
plot(Ta,x);
title(' x(t)'); xlabel('t-axis');
set(gca,'fontsize',16);
yf=zeros(N,1);
xf=zeros(N,1);
for t_cnt=1:N
% convolution integral : y(t)=h(t)*x(t) =
intetal(0-t)x(tau)*h(t-tau)*dtau
for k=1:t_cnt
if t_cnt - k+1 >0 && t_cnt - k+1 <=length(ht)
y(t_cnt)=y(t_cnt) + x(k)*ht(t_cnt - k+1)*dT;
end

end % for k=1:t_cnt
xf(1:t_cnt)=x(1:t_cnt); % input
yf(1:t_cnt)=y(1:t_cnt); % output

figure(6);
plot(Ta,xf);
hold on;
plot(Ta,yf,'r'); ylim([-1 1]);
pause(0.1);
hold off;

end % for t_cnt=1:N
%% Do it yourself
Show transcribed image text
PROBLEM 6 (10pts) in the class Let's set the filter_simulation.m code that we covered. (N=2001, T=2, td=200*dT, wd=W/30) convolution integral: y(t)-h convolution integral: y(t)=ht ws-Wa( (N+1)/2 +20 ); f_signal1=cos(ws Ta); % x=f_signal1'; y-zeros(N, 1); For each case, the following response can be obtained. 0.8 0.6 0.4 0.2 - 0.8 0.6 0.4 0.2 OFW -0.2 -0.4 -0.6 -0.8 -1 ws-Wa( (N+1)/2 +50); X f_signal1=cos(ws* Ta): % x=f_signal1'; y-zeros(N.1); U of -0.2 -0.4 -0.6 -0.8 -1 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 (a) Write the input, output, and impulse response of this experiment as a formula, and describe the relationship between output, input, and impulse response. (b) The output between t=0s and t=0.3s shows aperiodic transient response characteristics. Discuss the cause. (c) Using MATLAB, analyze and discuss the frequency response characteristics of the above system.