Question

Write a Matlab code to generate the signal y(t)=10*(cos(2*pi*f1*t)+ cos(2*pi*f2*t)+ cos(2*pi*f3*t)), where f1=500 Hz, f2=750 Hz...

Write a Matlab code to generate the signal y(t)=10*(cos(2*pi*f1*t)+ cos(2*pi*f2*t)+ cos(2*pi*f3*t)), where f1=500 Hz, f2=750 Hz and f3=1000 Hz. Plot the signal in time domain.

  1. Sketch the Fourier transform of the signal with appropriately generating frequency axis.
  2. Apply an appropriate filter to y(t) so that signal part with frequency f1 can be extracted. Sketch the Fourier transform of the extracted signal.
  3. Apply an appropriate filter to y(t) so that signal part with frequency f2 can be extracted. Sketch the Fourier transform of the extracted signal.
  4. Apply an appropriate filter to y(t) so that signal part with frequency f3 can be extracted. Sketch the Fourier transform of the extracted signal.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Code to plot the signal in time domain

clc;
clear all;
close all;

f1 = 500;
f2 = 750;
f3 = 1000;

t = 0:0.0000001:0.05;
y = 10*(cos(2*pi*f1*t) + cos(2*pi*f2*t) + cos(2*pi*f3*t));


plot(t,y);
grid on;
xlabel('Time, t(s)');
ylabel('y(t)');
title('Plot of the signal y(t)');

After running the code, we get the following plot

To sketch the Fourier Transform of the Signal

MATLAB Code

clc;
clear all;
close all;

f1 = 500;
f2 = 750;
f3 = 1000;

fs = 3*f3;
Ts = 1/fs;

n = 0:1000;
y = 10*(cos(2*pi*f1*n*Ts) + cos(2*pi*f2*n*Ts) + cos(2*pi*f3*n*Ts));
w = 0:pi/100000:pi;
Y = y*exp(-j*n'*w);


figure
plot(w/(2*pi)*fs,abs(Y));
grid on;
xlabel('Frequecny, f (Hz)');
ylabel('|Y(\Omega)|');
title('Magnitude Spectrum of the input Signal');

After running the code we get the output as

To extract the frequency f1

We have to use a low pass filter with a cut off frequency greater than 500Hz. So I am using 600 Hz. I am using a Butterworth filter with an order of 31

MATLAB Code

clc;
clear all;
close all;

f1 = 500;
f2 = 750;
f3 = 1000;

fs = 3*f3;
Ts = 1/fs;

n = 0:1000;
y = 10*(cos(2*pi*f1*n*Ts) + cos(2*pi*f2*n*Ts) + cos(2*pi*f3*n*Ts));
w = 0:pi/100000:pi;

[b,a] = butter(31,2*600/fs); % Butterworth Low Pass filter of order 31 and cut off frequency of 600 Hz
yout = filter(b,a,y);

w = 0:pi/100000:pi;
Yout = yout*exp(-j*n'*w);
figure
plot(w/(2*pi)*fs,abs(Yout));
grid on;
xlabel('Frequecny, f (Hz)');
ylabel('|Y_{0ut}(\Omega)|');
title('Magnitude Spectrum of the output Signal');

The result obtained

From the frequency response plot we can see that the signal with frequency 500 Hz is extracted

To extract the frequency f2

We have to use a band pass filter with a cut off frequency greater than 500Hz and less than 1000Hz.. So I am using 600 Hz and 900 Hz as the cut off frequencies.  I am using a Butterworth filter with an order of 31

MATLAB Code

clc;
clear all;
close all;

f1 = 500;
f2 = 750;
f3 = 1000;

fs = 3*f3;
Ts = 1/fs;

n = 0:1000;
y = 10*(cos(2*pi*f1*n*Ts) + cos(2*pi*f2*n*Ts) + cos(2*pi*f3*n*Ts));
w = 0:pi/100000:pi;

[b,a] = butter(31,[2*600/fs 2*900/fs], 'bandpass'); % Butterworth Band Pass filter, Order 31 & cut off frequency 600 & 900Hz
yout = filter(b,a,y);

w = 0:pi/100000:pi;
Yout = yout*exp(-j*n'*w);
figure
plot(w/(2*pi)*fs,abs(Yout));
grid on;
xlabel('Frequecny, f (Hz)');
ylabel('|Y_{0ut}(\Omega)|');
title('Magnitude Spectrum of the output Signal');

The result obtained

From the frequency response plot we can see that the signal with frequency 750 Hz is extracted

To extract the frequency f3

We have to use a high pass filter with a cut off frequency greater than 750Hz and less than 1000Hz. So I am using 900 Hz. I am using a Butterworth filter with an order of 31

MATLAB Code

clc;
clear all;
close all;

f1 = 500;
f2 = 750;
f3 = 1000;

fs = 3*f3;
Ts = 1/fs;

n = 0:1000;
y = 10*(cos(2*pi*f1*n*Ts) + cos(2*pi*f2*n*Ts) + cos(2*pi*f3*n*Ts));
w = 0:pi/100000:pi;

[b,a] = butter(31, 2*900/fs, 'high'); % Butterworth High Pass filter of order 31 and cut off frequency of 900 Hz
yout = filter(b,a,y);

w = 0:pi/100000:pi;
Yout = yout*exp(-j*n'*w);
figure
plot(w/(2*pi)*fs,abs(Yout));
grid on;
xlabel('Frequecny, f (Hz)');
ylabel('|Y_{0ut}(\Omega)|');
title('Magnitude Spectrum of the output Signal');

The result obtained

From the frequency response plot we can see that the signal with frequency 1000 Hz is extracted

Add a comment
Know the answer?
Add Answer to:
Write a Matlab code to generate the signal y(t)=10*(cos(2*pi*f1*t)+ cos(2*pi*f2*t)+ cos(2*pi*f3*t)), where f1=500 Hz, f2=750 Hz...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT