Question: equation 2 Instructor Verification (separate page) 2.2 Sinusoidal Synthesis with an M-File Write an M-file that will synthesize a waveform in the form of (2).

equation 2
Instructor Verification (separate page) 2.2 Sinusoidal Synthesis with an M-File Write an M-file that will synthesize a waveform in the form of (2). Write the function without using for loops. Take advantage of the fact that matrix-vector multiplication computes a sum of products. For example, c - Ab o n-Lankok (10) where CR represents the element of the vector c, nk is the element in the throw and 4th column of the matrix A, is the Ath element of the vector b, and L is the number of columns in A. The first few statements of the M-file should look like II = sumcos(f, z, fs, dur) %SUMCOS Function to synthesize a sum of cosine waves % usage: II = sumcos(f, z, fs, dur) % f = vector of frequencies (these could be negative or positive) Z = vector of complex exponentials: Amp*e(j*phase) fs = the sampling rate in Hz dur = total time duration of signal Note: f and Z must be the same length Z(1) corresponds to frequency f(1), Z(2) corresponds to frequency f(2), etc. The MATLAB syntax length(f) returns the number of elements in the vector f. so we do not need a separate input argument for number of frequencies. On the other hand, the programmer should provide error checking to make sure that the lengths of f and Z are the same. It is possible (although not required) to complete this function in a single line. For some hints, please refer to the review of matrix multiplication in the Using MATLAB Appendix of the text. In order to use this M-file to synthesize periodic waveforms, yoll would simply choose the entries in the frequency vector to be integer multiples of the desired fundamental frequency. Try the following test and plot the result. XX - sumcos( [20], [1], 200, 0.25); xx = sumcos( [20 40). [1 1/2), 200, 0.25); xx - sumcos((20 40 60 801, [1 -1 1 -1], 200, 0.25); Instructor Verification (separate pase) Instructor Verification (separate page) 2.2 Sinusoidal Synthesis with an M-File Write an M-file that will synthesize a waveform in the form of (2). Write the function without using for loops. Take advantage of the fact that matrix-vector multiplication computes a sum of products. For example, c - Ab o n-Lankok (10) where CR represents the element of the vector c, nk is the element in the throw and 4th column of the matrix A, is the Ath element of the vector b, and L is the number of columns in A. The first few statements of the M-file should look like II = sumcos(f, z, fs, dur) %SUMCOS Function to synthesize a sum of cosine waves % usage: II = sumcos(f, z, fs, dur) % f = vector of frequencies (these could be negative or positive) Z = vector of complex exponentials: Amp*e(j*phase) fs = the sampling rate in Hz dur = total time duration of signal Note: f and Z must be the same length Z(1) corresponds to frequency f(1), Z(2) corresponds to frequency f(2), etc. The MATLAB syntax length(f) returns the number of elements in the vector f. so we do not need a separate input argument for number of frequencies. On the other hand, the programmer should provide error checking to make sure that the lengths of f and Z are the same. It is possible (although not required) to complete this function in a single line. For some hints, please refer to the review of matrix multiplication in the Using MATLAB Appendix of the text. In order to use this M-file to synthesize periodic waveforms, yoll would simply choose the entries in the frequency vector to be integer multiples of the desired fundamental frequency. Try the following test and plot the result. XX - sumcos( [20], [1], 200, 0.25); xx = sumcos( [20 40). [1 1/2), 200, 0.25); xx - sumcos((20 40 60 801, [1 -1 1 -1], 200, 0.25); Instructor Verification (separate pase)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
