Question

In: Electrical Engineering

Problem 4 ..... you can use Matlab Using the same initial code fragment as in Problem...

Problem 4 ..... you can use Matlab

Using the same initial code fragment as in Problem 1, add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the impulse response of an IIR bandstop filter with band edge frequencies 750 Hz and 850 Hz and based on a 4th order Butterworth prototype. Name your program p3.sce

the below is the Problem 1 initail code .. you can use it Matlab

The following cilab code generates a 10-second “chirp” with discrete frequencies ranging from 0 to 0.2 with a sampling frequency of 8 kHz.

clear; Fs = 8000; Nbits = 16; tMax = 10; N = Fs*tMax+1; f = linspace(0.0,0.2,N); x = zeros(f); phi = 0; for n=0:N-1 x(n+1) = 0.8*sin(phi); phi = phi+2*%pi*f(n+1); end sound(x,Fs,Nbits); sleep(10000); //allows full sound to play

Solutions

Expert Solution

Matlab code:-

clear;
Fs = 8000;
Nbits = 16;
tMax = 10;
N = Fs*tMax + 1;
f = linspace(0.0,0.2,N);
x = zeros(size(f));
phi = 0;
for n = 0:N-1
    x(n+1) = 0.8*sin(phi);
    phi = phi + 2*pi*f(n+1);
end

sound(x,Fs,Nbits);
pause(10);

fc = 800;
n = 100;                          % filter having 101 elements
Wn = (fc/Fs)*pi;
ftype = 'low';
h = fir1(n,Wn,ftype);
y_low = filter(h,1,x);
sound(y_low,Fs,Nbits);
pause(10);
plot(f,y_low);
xlabel('Freq (Hz)');
title('Low pass output plot vs Freq');

ftype = 'high';
h = fir1(n,Wn,ftype);
y_hi = filter(h,1,x);
sound(y_hi,Fs,Nbits);
pause(10);

figure;
plot(f,y_hi);
xlabel('Freq (Hz)');
title('High pass output plot vs Freq');

Output:-


Related Solutions

How can I code this problem in MATLAB: a) Find the approximations to within 10-4 to...
How can I code this problem in MATLAB: a) Find the approximations to within 10-4 to all real zeros of the following polynomials using Newton's method.? f(x)=x3 - 2*x2- 5. b) Find approximations to within 10-5 to all the zeros of each of the following polynomials by first finding the real zeros using Newton’s method and then reducing to polynomials of lower degree to determine any complex zeros. f(x)=x4 + 5x3 - 9*x2 - 85*x - 136.
write a matlab code to find the following: initial position, initial velocity, and acceleration using the...
write a matlab code to find the following: initial position, initial velocity, and acceleration using the algorithm and information below time(seconds). height(m) velocity(m/s) 0. 0.2. 2.95 algorithm: 1. Enter data in to arrays. 2. Fit the height data to a 2nd order polynomial. 3. Evaluate the polynomial at enough points to get a smooth curve. 4. Find the velocity model by taking derivative of the height polynomial. 5. Evaluate the velocity polynomial at enough times to get a smooth curve
Can you rewrite this MATLAB code using a for loop instead of a while loop? %formatting...
Can you rewrite this MATLAB code using a for loop instead of a while loop? %formatting clc, clear, format compact; %define variables k=1; b=-2; x=-1; y=-2; %while loop initialization for k <= 3 disp([num2str(k), ' ',num2str(b),' ',num2str(x),' ',num2str(y),]); y = x^2 -3; if y< b b = y; end x = x+1; k = k+1; end
Solve using matlab code The initial value problem dydx−y= 2 cosx, y(0) =−2 has the exact...
Solve using matlab code The initial value problem dydx−y= 2 cosx, y(0) =−2 has the exact solution y(x) =−e^x −√2 cos (x+π4). Use the Euler method to solve the initial value problem for 0≤x≤2 using n=10,50,100,200 and plot solutions in one graph. Repeat #1 using the Runge-Kutta method and plot solutions in one graph with the exact solution
Prove that √3 is irrational using contradiction. You can use problem 4 as a lemma for...
Prove that √3 is irrational using contradiction. You can use problem 4 as a lemma for this. Problem 4, for context is Prove that if n2 is divisible by 3, then n is divisible by 3.
Write a Matlab code that simulates three- body problem with any given masses, initial positions and...
Write a Matlab code that simulates three- body problem with any given masses, initial positions and velocities. Also give a set of data that generates an interesting orbit.
In this problem, you can use the Matlab program posted on course website and Canvas (also...
In this problem, you can use the Matlab program posted on course website and Canvas (also given in the lecture) that computes the interpolation polynomial. We want to see how well a given function can be approximated by the interpolation polynomials. Let f be a function. We divide the the interval [−0.6,0.6] into subintervals of the same length h = 0.02. The gridpoints are −0.6 = x1 < x2 < ... < x61 = 0.6. Take N = 61 points...
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...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a minimum and maximum real number, then generates and prints a random number in the requested range. The script should then do the same for an integer range. Sample output: Enter a minimum real value: 0.5 Enter a maximum real value: 30 A random number in the range ( 0.5000, 30.0000 ) is 1.7851 Enter a minimum integer value: -10 Enter a maximum integer...
Write a Matlab code that simulates three-body problem tridimensional with any given masses, initial positions, and...
Write a Matlab code that simulates three-body problem tridimensional with any given masses, initial positions, and velocities. Plotting the trajectory of all the masses.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT