MATLAB PROBLEM: A simple low-pass filter circuit has frequency response given by
ID: 1716915 • Letter: M
Question
MATLAB PROBLEM:
A simple low-pass filter circuit has frequency response given by H() = 1 / (1+j/0) where j = (-1) and 0 is called the corner frequency (units: rad/s). Write a MATLAB script to plot the magnitude and phase of H(). The script should prompt the user to enter the corner frequency. Create a logarithmic frequency axis which ranges from about two decades below to about two decades above 0. Use subplot to show both magnitude and phase of H on separate graphs. The magnitude plot, |H|, should be in decibels which is 20 log |H| (label this y-axis "Magnitude (dB)") and the phase plot, H, should be in radians (label this y-axis "Phase (rad)"). Hint: Compute H as a complex-valued function of then obtain magnitude and phase for the plots. Test your script using 0 = 42x105.
Explanation / Answer
wo=input('enter the corner frequency');
w=(wo/20):1:(wo*20);
H=1./(1+((1i)*w/wo));
mag_h=abs(H);
ang_h=angle(H);
subplot(2,1,1);
semilogx(w,20*log(mag_h));
xlabel('freq in radians');
ylabel('Magnitude (dB)');
subplot(2,1,2);
semilogx(w,ang_h);
xlabel('freq in radians')
ylabel('Phase (rad)');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.