Question

In: Electrical Engineering

Matlab Code that does the following: Takes as input 3 frequencies. Create a signal that is...

Matlab Code that does the following:

Takes as input 3 frequencies.

Create a signal that is a mixture of the 3 signals. Create a bandpass filter that only selects the center

frequency.

Output the filtered signal which contains only the middle frequency.

Plot in time and frequency domain the original signal and the filtered signal. Show the output for filter

order 1 and 15. Upload a pdf of the image files. Each figure should have your name in the title of the

submission.

Solutions

Expert Solution

clc
clear all
close all
fs = 600;
t = 0:1/fs:.5;
N=10;
x = sin(2*pi*50*t)+sin(2*pi*150*t)+sin(2*pi*250*t);
d=fdesign.bandpass('N,F3dB1,F3dB2',N,100,200,fs);
Hd=design(d,'butter');
y=filter(Hd,x);
subplot(2,1,1)
plot(t,x)
title('Input signal')
xlabel('time')
ylabel('Amplitude')
subplot(2,1,2)
plot(t,y,'-r')
title('Filtered signal')
xlabel('time')
ylabel('Amplitude')

figure;
freq=0:(2*pi)/length(x):pi;
X=fft(x);
Y=fft(y);
plot(freq,abs(X(1:length(x)/2+1)))
hold on
plot(freq,abs(Y(1:length(x)/2+1)),'-r')
hold off
xlabel('Normalized Frequency (\times\pi rad/sample)')
legend('Original Signal','Bandpass Signal')
title(['Frequency Response of input and filtered signal for order N=',num2str(N)])

For N=10;

For N=1;

In the title you can add your name. Change N value to change the order which will give you corresponding plot.


Related Solutions

Matlab Create/write a function that takes an input of x and y data, and a string...
Matlab Create/write a function that takes an input of x and y data, and a string (either linear? or quadratic), sets up a linear system of equations (Ax = b), and solves and plots the model.
In matlab using a RC low pass filter Create a 1 Hz input signal (with amplitude...
In matlab using a RC low pass filter Create a 1 Hz input signal (with amplitude of one). Corrupt the input signal with signals greater than or equal to 100 Hz and/or random noise. Use randn(length(v_in,1)) to test filter
Write a recursive function (using Matlab) moreFactors(a,b,fact) that does the following: 1. Takes as an input...
Write a recursive function (using Matlab) moreFactors(a,b,fact) that does the following: 1. Takes as an input 3 positive integers. 2. Of the two integers a and b, the function returns the integer that has the most factors fact. 3. If both integers a and b have the same amount of factors fact, the function will return the larger integer. Test your function with the following: >> result=moreFactors(24,32,3) result = 24 (24 = 3^1 · 2^3 , 32 = 2^5 )...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following problem using problem specifications: Plot x vs y when y=sin(x), y=cos(x), y=sin (2*x), and y=2*sin(x) when x = 1:0.1:10. Use 2 by 2 subplot, sin(x) is in location 1, cos(x) is in location 2, sin(2*x) is in location 3 and 2*sin(x) is in location 4. The plot should have: (1) x label = ‘x value’, y label = ‘y value’, legend ‘y=sin(x)’,’ y=cos(x)’,’ y=sin...
Make the following matlab function. D=inverses(A) It takes the input of an nxn matrixA. First, the...
Make the following matlab function. D=inverses(A) It takes the input of an nxn matrixA. First, the function has to determine whether A is invertible (you may want to use the function rank to do that). If A is not invertible, the function has to return an empty matrix D=[ ]; and terminates with a message “Matrix A is not invertible”. If A is invertible, then the function reduces the matrix [A eye(n)] into the reduced echelon form and returns the...
Need explanation of MATLAB code which creates echo. (SIGNAL PROCESSING) If the original audio signal is...
Need explanation of MATLAB code which creates echo. (SIGNAL PROCESSING) If the original audio signal is x(t) then the echo is y(t) = x(t) + alpha*x(t-delay) This code below creates this echo however I don't understand how every line of the code works, could someone comment this code so I can understand? [x,Fs] = audioread('Hallelujah.wav'); sound(x,Fs); delay = 0.5; % 0.5s delay alpha = 0.65; % echo strength D = delay*Fs; y = zeros(size(x)); y(1:D) = x(1:D); for i=D+1:length(x) y(i)...
Please provide Python code that does the following: 3) Write a program that takes a string...
Please provide Python code that does the following: 3) Write a program that takes a string as input, checks to see if it is comprised entirely of letters, and if all those letters are lower case. The output should be one of three possible messages: Your string is comprised entirely of lower case letters. Your string is comprised entirely of letters but some or all are upper case. Your string is not comprised entirely of letters. Your program may NOT:...
A. Write a function in MATLAB called findTranspose that takes in as input any matrix or...
A. Write a function in MATLAB called findTranspose that takes in as input any matrix or any vector and simply returns back the transpose of that input. You can always verify your answer by using the inbuilt transpose function in MATLAB, however, you cannot use the transpose function directly when writing your code. Here is the starter code that we are providing to help you get started %x is the input vector or matrix. You can find the %size that...
Write a function in Matlab that takes as input the number n and a symmetric tridiagonal...
Write a function in Matlab that takes as input the number n and a symmetric tridiagonal matrix given as two vectors: n×1 vector v representing the main diagonal and (n−1)×1 vector w representing the upper diagonal. Have this function output the Cholesky factor of the matrix as a vector for the main diagonal and a vector for the upper diagonal and output the number of flops and, separately, the number of square roots used as well. Use only basic programming....
Using Matlab, write a function that takes numeric data as its input argument and prints a...
Using Matlab, write a function that takes numeric data as its input argument and prints a message to the Command Window stating if the number is positive, or negative, or 0. This function should transfer an output value to the Workspace ONLY when the input value is negative. Please include a copiable code and the associated screenshots.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT