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

Data Acquisition with MATLAB Open MATLAB and enter the following function into a

ID: 1716899 • Letter: D

Question

Data Acquisition with MATLAB   
Open MATLAB and enter the following function into a new function file, and save it in your current folder.
% Function to record microphone input % Written by R. Priemer, 8/21/11 function [Mic_record] = mic_recorderF(rec_time,fs,N_bits) N_chan = 1; % specify 1 or 2 channels mic_record = audiorecorder(fs,N_bits,N_chan); % set recording parameters disp('Press enter key to start recording') pause recordblocking(mic_record,rec_time); % recording disp('End of recording') % play(mic_record); % play MATLAB formatted recording (optional) Mic_record = getaudiodata(mic_record); % column vector of recorded signal
The function places the sampled audio data into the vector Mic_record. To obtain, for example, t_total = 2 seconds of recorded sound, sampled at the rate fs = 44100 samples/second, with the sampled data returned in the vector x, use the following MATLAB statements.
% MATLAB script for audio data acquisition clear all; clc t_total = 2; fs = 44100; % sample time duration and sampling rate N_bits = 16; % number of bits per sample x = mic_recorderF(t_total,fs,N_bits); % returns column vector of sampled signal K = length(x); % number of samples t_index = 0:K-1; T = 1/fs; t = t_index*T; % define K time points
The elements of the vector x are the samples of the sound in time sequence, where x(1) is the sample when recording started at t=0, and x(K) is the sample when recording ended at the time t=(K-1)T. With respect to x(K), x(1) is a sample of the audio signal in the past. You can change t_total to a different recording time. To hear the recorded sound, use the MATLAB function soundsc, as in the following MATLAB statement.
soundsc(x, fs); % send the sampled data to the computer's sound board pause(t_total); % wait to hear sound
To create a WAV file of the recorded sound, first create a stereo recording and then use the MATLAB function audiowrite, as in the following MATLAB statements.
y = [x x]; % y contains two columns, the left and right audio channels file_name = 'my_sound.WAV' ; % you can make up your own file name audiowrite(file_name,y,fs,'BitsPerSample',16)
The second column in y does not have to be a duplicate of x. The second column could be some other digital sound recording. MATLAB will store the WAV file in your current folder. You can use any software, for example, Microsoft's multimedia application, that plays WAV files to hear the sound.   
Experiment
All plots must include: grid, xlabel, ylabel and title statements. Precede each plot statement with a figure statement. For example, .
. figure(1) plot( . . . ) . . figure(2) plot( . . . ) . .
Thereby, all of your figures will be numbered.
1) Start a MATLAB script with the given MATLAB script for audio data acquisition, and append a sound statement to the given script. Execute the program to record yourself speaking your first name.
2) Append to the MATLAB statements of part (1) statements to plot the recorded signal and create a WAV file of the recorded signal. Use your first name for the file name. Execute the program to record yourself speaking your first name.
3) Append the following MATLAB statement.
z = flipud(x); % use doc flipud to find out what this function does
Continue by appending statements that plot and sound z. Execute the program to record yourself speaking your first name. How is the sound of z different from the sound of x?
4) Append the following MATLAB statements.
D1 = floor(K/20); D2 = 2*D1; % delay times w(1:D2) = x(1:D2); % duplicating the first D2 samples of x for n = D2+1 : K % creating w(n) for n = D2+1 to n = K w(n) = 0.5*x(n) + 0.25*x(n - D1)+0.125*x(n - D2); end   
Continue by appending statements that plot and sound w. Execute the program to record yourself speaking your first name. Explain the sound of w. Try larger and smaller values of D1. Explain what happens as D1 is increased.
5) Append the following MATLAB statements.
M = floor(K/2); for n = 1:M v(n) = x(2*n); end
Explain the relationship between the audio signal samples stored in x and those stored in v. For v, what is the appropriate value of the sampling frequency? Continue by appending statements that plot (You will have to change the time scale.) and sound v. Execute the program to record yourself speaking your first name. Is the sound of v intelligible? Which vector v or x requires less file space?
6) Append the following MATLAB statements.
p = max(abs(x))/20; % used to limit noise contribution to u u = (1-p)*x + p*randn(K,1); % adding noise to x
Continue by appending statements that plot and sound u. Execute the program to record yourself speaking your first name. Is the sound of u intelligible?   
7) Append the following MATLAB statements.
% Processing the number sequence u with a digital low-pass filter. To find % values for the elements of a requires an understanding of the topics covered % in ECE 317. a = [-4.746161 9.014062 -8.563359 4.069240 -0.7737809]; b = 1+sum(a); % used to scale the input signal u S = zeros(5,1); % initialize a column vector to all zeros for n=1:K; % process u(n) to obtain s(n) s(n) = b*u(n)-a*S; % a recursion S = [s(n); S(1:4)]; % shift number sequence s and place s(n) at top of S end These MATLAB statements implement an algorithm that is an example of digital signal processing to do low-pass filtering, which is determined by the elements of the vector a. Continue by appending statements that plot and sound s. Execute the program to record yourself speaking your first name. Discuss how the sound of s is different from the sound of u. Also, if, for example, the signal x contained sound from a bass guitar and sound from a violin, which instrument will have its contribution to x reduced in the signal s?
Parts (4), (5), (6) and (7) are simple examples of different kinds of digital signal processing. Try recording another sound. For example, increase t_total, and record yourself speaking (or singing) a sentence.
Your report should include your program, plots of all signals, and your discussions

Explanation / Answer

Please mention question clearly . The function file is not in proper manner . Its very difficult to understand which part is program and which part is commented