Butterworth filter sample !!PLease SHOW MATLAB code and the output (graphs) 1) B
ID: 2250305 • Letter: B
Question
Butterworth filter sample
!!PLease SHOW MATLAB code and the output (graphs)
1) Basic modulation and demodulation Simple sine and cosine. Here we will investigate the modulation and demodulation of a simple baseband waveform with a carrier as shown in Figures 3 and 5. We will specifically examine what happens when we change the phase of the demodulating signal with respect to the phase of the original modulating signal. a. i. You will create a function called modcos that demonstrates modulation and demodulation. Here is a specification of the function: function modcos (theta, f0) % MODCOS Plot modulation and demodulation of a cosine with varying angles for demodulation. This function plots four panels 1) The first panel plots x(t)cos (2*pi*1*t) where t is the interval between -0.25 and 0.25 seconds sampled at 8000 samples/sec. 2) The second panel plots y(t)-x (t)c(t), where c(t)cos (2*pi 100*t) This is the modulated signal 3) The third panel plots r (t)-y (t) cos (2 pi 100*t+theta*pi) where theta is an angle (default 0) This is the demodulated signal before lowpass filtering 4) The fourth panel plots the lowpass filtered version of r (t) using lsim. The filter selected is a second order Butterworth lowpass filter with cutoff frequency 0 (default 20) You can create the Butterworth filter with this little Matlab program, makefilt. You can examine at the frequency response of this filter using Matlab's bode or ltiview function. To do the filtering, create the filter with makefilt(f0, 2), then filter using z-lsim (filt, t). Here is the result of modcos (0, 20): r,Explanation / Answer
Solution :
function modcos(theta,f0)
if(nargin<2)
display('Input arguments to the function are unexpected! Assigning default values...');
theta = 0;
f0 = 20;
end
Ts = 1/8000 ;
fs = 1/Ts;
t = [-0.25:Ts:0.25];
%first panel
x_t = cos(2*pi*1.*t);
subplot(411),plot(t,x_t);
axis([-0.25 0.25 -1 1]);
xlabel('t')
ylabel('x(t) = cos(2*pi*1*t)');
grid on;
%second panel
c_t = cos(2*pi*100.*t);
y_t = x_t.*c_t;
subplot(412),plot(t,y_t),hold on,plot(t,x_t,'r') ;
axis([-0.25 0.25 -1 1]);
xlabel('t')
ylabel('y(t) = x(t) cos(2*pi*100*t)');
legend('modulated signal','Original signal')
grid on;
%third panel
r_t = y_t.*cos(2*pi*100.*t + theta*pi);
subplot(413),plot(t,r_t),hold on,plot(t,x_t,'r') ;
axis([-0.25 0.25 -1 1]);
xlabel('t')
ylabel('r(t) = y(t) cos(2*pi*100*t+theta*pi)');
legend('demodulated signal','Original signal')
grid on;
%fourth panel
[b a] = butter(2,f0/(fs/2));
final = filter(b,a,r_t);
subplot(414),plot(t,final),hold on,plot(t,x_t,'r') ;
axis([-0.25 0.25 -1 1]);
xlabel('t')
ylabel('filterred data');
legend('final output','Original signal')
grid on;
end
%******************
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.