Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

frequency Write a MATLAB function named, which performs the following operations

ID: 2249949 • Letter: F

Question

frequency

Write a MATLAB function named, which performs the following operations:

a) asks the user to enter 10 characters (see table) (if an invalid character is entered it needs to make the user enter another value)

b) For each character, your code should produce summation of two sinusoids (each with unity amplitude) whose duration is exactly 0.20 sec.

c) Then your code should concatenate the signals produced for all characters by inserting a zero signal of duration about 0.05 sec. long, between these signals.

d) you should be able to listen to the signal produced

e) write another function that takes the signal produced from step d

f) it should partition the sound signal into short time segments representing individual characters where each segment duration is 0.20 sec and there is a silence period of 0.05 sec

g) it should filter the individual segments to extract the possible frequency components by employing a bank of bandpass filters to isolate the sinusoidal components. Basically, it should figure out which two frequency components are present in each time segment by considering the outputs of all of the bandpass filters. For that purpose, a filter bank of eight bandpass filters (depicted below) can be employed.

h) You can use the following impulse response form for each of the bandpass filters:

where fc is the center frequency of the bandpass filter and parameter beta should be

selected to make the maximum of magnitude response of the filter be one.

Therefore each filter may have a different beta value.

The important step is to determine the length of these filters, e.g., parameter N,

which should be selected so that only one frequency stays in the passband of the

bandpass filter and other frequencies should be in the stopband . Note that the

magnitude response in passband is close to one for our case and width of the

passband is the length of the frequency band over which magnitude response is

greater than 1/ root(2) . Also, it is okey to define the stopband as the frequency band

over which the magnitude response is less than 0.25.

Now, the minimum length of these filters (i.e., N ) should be empirically

determined by you so that the frequency response will satisfy the specifications on

passband width and stopband rejection stated above. For that purpose, try N=40,

N=50, N=60, N=80 an figure out the optimal length. Plot the magnitude response of

the eight filters (in the same plot) for the optimal length you have found .

Finally, your code should declare the character sequence based on the outputs of the filter bank as follows:

i. Assume the output of ith bandpass filter is denoted by You can declare presence of the sinusoidal component corresponding to the ith bandpass filter if [ ] i y n max | [ ] | 0.59 i n y n

ii. Determine two frequency components available corresponding to each character using (a)

iii. Output the character sequence.

frequency

1209 hz 1336 hz 1477 hz 1633 hz 697 hz 1 2 3 A 770 hz 4 5 6 B 852 hz 7 8 9 C 941 hz * 0 # D

Explanation / Answer

%tone_generation.m file
function a = tone_generation(freq1,freq2,fs,duration)

values=0:1/fs:duration;
a=amp*sin(2*pi* freq*values)
return;
end;

%main.m file

clc;
clear all;
close all;
fs = 20500

tone_signal = 0;
char_vec = 0;
while(i < 10)

char_vec(i) = input('Enter a Charactor:');
i = i + 1;
switch char_vec(i)
  case '1'
   tone_signal = [tone_signal tone_generation(697,1209,fs,0.20)];
  case '2'
   tone_signal = [tone_signal tone_generation(697,1336,fs,0.20)];
  case '3'
   tone_signal = [tone_signal tone_generation(697,1477,fs,0.20)];
  case 'A'
   tone_signal = [tone_signal tone_generation(697,1633,fs,0.20)];
  case '4'   
   tone_signal = [tone_signal tone_generation(770,1209,fs,0.20)];
  case '5'
   tone_signal = [tone_signal tone_generation(770,1336,fs,0.20)];
  case '6'
   tone_signal = [tone_signal tone_generation(770,1477,fs,0.20)];
  case 'B'
   tone_signal = [tone_signal tone_generation(770,1633,fs,0.20)];
  case '7'
   tone_signal = [tone_signal tone_generation(852,1209,fs,0.20)];
  case '8'
   tone_signal = [tone_signal tone_generation(852,1336,fs,0.20)];
  case '9'
   tone_signal = [tone_signal tone_generation(852,1477,fs,0.20)];
  case 'C'
   tone_signal = [tone_signal tone_generation(852,1633,fs,0.20)];
  case '*'
   tone_signal = [tone_signal tone_generation(941,1209,fs,0.20)];
  case '0'
   tone_signal = [tone_signal tone_generation(941,1336,fs,0.20)];
  case '#'
   tone_signal = [tone_signal tone_generation(941,1477,fs,0.20)];
  case 'D'  
   tone_signal = [tone_signal tone_generation(941,1633,fs,0.20)];
  case otherwise
   i = i - 1;
   disp('Please Enter Corrct Character Only');   
end

end

sound(tone_signal,fs);