Modify the MATLAB script to plot the step response
function. Plot, also, the magnitude of the Fourier transform of the
step response function.
clear
close all
%
%*******Parameter Settings********
%
Fs=5000;
%Sampling Frequency
Ts=1/Fs;
%Sampling Period or Sampling Time
N=200;
%Length of each discrete signal or
vector
V=N*Ts;
%Time duration (in seconds) for each
signal
fm=600;
%Cut-off frequency
Wn=2*fm/Fs;
%Normalized frequency
M=200;
%Length of the impulse response
signal
R=100;
%Value of Resistor
C=1/(2*pi*fm*R); %Value of
Capacitor
a=1/(R*C);
%Time Constant Parameter
h0=a;
%Initial Condition Parameter
t=0:Ts:V-Ts;
%General time axis
th=0:Ts:M*Ts-Ts; %Time
axis to plot impulse response signal
f=-Fs/2:Fs/M:Fs/2-Fs/M; %Frequency axis
%
%CAUSAL FIRST-ORDER LOW-PASS RC-FILTER
%
hRC=h0*exp(-a*th); %RC-Filter impulse response
function
hmax=max(hRC); %Maximum value of
impulse response function
hRC=(hRC/hmax); %Normalized impulse
response function
fhRC=fft(hRC); %Fourier Transform
of impulse response function
sfhRC=fftshift(fhRC); %Frequency shift for two-sided
spectrum plot
asfhRC=abs(sfhRC); %Absolute value
calculation
Hmax=max(asfhRC); %Maximum value of frequency
response function
asfhRC=(asfhRC/Hmax); %Normalized frequency response
function
%
%MATLAB IDEAL FIR APPROXIMATION FILTER
%
Wn=(2*fm)/Fs; %Normalized
cut-off frequency for ideal filter
h=fir1(N-1,Wn); %Impulse response
function of ideal filter
fh=fft(h); %Fourier
transform of impulse response function
sfh=fftshift(fh); %Frequency shift for
two-sided spectrum plot
msfh=abs(sfh); %Absolute value calculation
%
%*********************************
%**********Signals Plots**********
%********************************* %
plot(f,asfhRC,f, msfh,'r') %Plots of RC & Ideal
filters
% grid
xlabel('Frequency in Hz.') %Horizontal axis
ylabel('Magnitude') %Vertical
axis
title('HL(f) and HRC(f)') %Title of plot
%
figure
plot(f,20*log10(asfhRC),f,20*log10(msfh),'r') %Plots of RC &
Ideal filters
grid
xlabel('Frequency in Hz.') %Horizontal
axis
ylabel('20*Log10 (Magnitude)') %Vertical axis
title('HL(f) and HRC(f)') %Title of plot
axis([min(f) max(f) -100 +50]);
Modify the MATLAB script to plot the step response function. Plot, also, the magnitude of the Fourier transform of the s
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Modify the MATLAB script to plot the step response function. Plot, also, the magnitude of the Fourier transform of the s
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!