expressions are equivalent if we define the complex amplitudes X as X = Ake == x(1) = R 이혼 N XkeJ N x(t) = Ak cos(2πfkt+k) k=1 4.2.1 Write the Function M-file (7) (8) Write an M-file called syn_sin.m that will synthesize a waveform in the form of (7). Although for loops are rather inefficient in MATLAB, you must write the function with one loop in this lab. The first few statements of the M-file are the comment lines-they should look like: [xx, tt] syn sin (fk, Xk, fs, dur, tstart) Function to synthesize a sum of cosine waves function SYN_SIN usage: % [xx, tt] % fk % Xk 용 fs dur tstart xx tt syn sin (fk, Xk, fs, dur, tstart) vector of frequencies (these could be negative or positive) vector of complex amplitudes: Amp*e (j*phase) the number of samples per second for the time axis total time duration of the signal starting time (default is zero, if you make this input optional) vector of sinusoidal values vector of times, for the time axis Note: fk and Xk must be the same length. Xk (1) corresponds to frequency fk (1), Xk (2) corresponds to frequency fk (2), etc. The MATLAB syntax length (fk) returns the number of elements in the vector fk, so we do not need a separate input argument for the number of frequencies. On the other hand, the programmer (that's you) should provide error checking to make sure that the lengths of fk and Xk are the same. See help error. Finally, notice that the input fs defines the number of samples per second for the cosine generation; in other words, we are no longer constrained to using 20 samples per period. Include a copy of the MATLAB code with your lab report. 4.2.2 Default Inputs You can make the last input argument(s) take on default values if you use the nargin operator in MATLAB. For example, tstart can be made optional by including the following line of code: 4.2.3 Testing if nargin<5, tstart=0, end --default value is zero In order to use this M-file to synthesize harmonic waveforms, you must choose the entries in the frequency vector to be integer multiples of some desired fundamental frequency. Try the following test and plot the result. [xx0, tt0] syn sin([0, 100, 250], [10, 14*exp(-1*pi/3), 8-11, 10000, 0.1, 0); -Period = ? Measure the period of xx0 by hand. Then compare the period of xx0 to the periods of the three sinusoids that make up xx0, and write an explanation on the verification sheet of why the period of xx0 is longer. Instructor Verification (separate page)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 12E: (Program) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

please help me complete 4.2.1 and 4.2.3.  I will like

expressions are equivalent if we define the complex amplitudes X as X = Ake
==
x(1) =
R
이혼
N
XkeJ
N
x(t) =
Ak cos(2πfkt+k)
k=1
4.2.1 Write the Function M-file
(7)
(8)
Write an M-file called syn_sin.m that will synthesize a waveform in the form of (7). Although for loops are rather
inefficient in MATLAB, you must write the function with one loop in this lab. The first few statements of the M-file are
the comment lines-they should look like:
[xx, tt] syn sin (fk, Xk, fs, dur, tstart)
Function to synthesize a sum of cosine waves
function
SYN_SIN
usage:
%
[xx, tt]
%
fk
%
Xk
용
fs
dur
tstart
xx
tt
syn sin (fk, Xk, fs, dur, tstart)
vector of frequencies
(these could be negative or positive)
vector of complex amplitudes: Amp*e (j*phase)
the number of samples per second for the time axis
total time duration of the signal
starting time (default is zero, if you make this input optional)
vector of sinusoidal values
vector of times, for the time axis
Note: fk and Xk must be the same length.
Xk (1) corresponds to frequency fk (1),
Xk (2) corresponds to frequency fk (2), etc.
The MATLAB syntax length (fk) returns the number of elements in the vector fk, so we do not need a separate input
argument for the number of frequencies. On the other hand, the programmer (that's you) should provide error checking
to make sure that the lengths of fk and Xk are the same. See help error. Finally, notice that the input fs defines
the number of samples per second for the cosine generation; in other words, we are no longer constrained to using 20
samples per period.
Include a copy of the MATLAB code with your lab report.
4.2.2 Default Inputs
You can make the last input argument(s) take on default values if you use the nargin operator in MATLAB. For
example, tstart can be made optional by including the following line of code:
4.2.3 Testing
if nargin<5, tstart=0, end
--default value is zero
In order to use this M-file to synthesize harmonic waveforms, you must choose the entries in the frequency vector to
be integer multiples of some desired fundamental frequency. Try the following test and plot the result.
[xx0, tt0] syn sin([0, 100, 250], [10, 14*exp(-1*pi/3), 8-11, 10000, 0.1, 0);
-Period = ?
Measure the period of xx0 by hand. Then compare the period of xx0 to the periods of the three sinusoids that make
up xx0, and write an explanation on the verification sheet of why the period of xx0 is longer.
Instructor Verification (separate page)
Transcribed Image Text:expressions are equivalent if we define the complex amplitudes X as X = Ake == x(1) = R 이혼 N XkeJ N x(t) = Ak cos(2πfkt+k) k=1 4.2.1 Write the Function M-file (7) (8) Write an M-file called syn_sin.m that will synthesize a waveform in the form of (7). Although for loops are rather inefficient in MATLAB, you must write the function with one loop in this lab. The first few statements of the M-file are the comment lines-they should look like: [xx, tt] syn sin (fk, Xk, fs, dur, tstart) Function to synthesize a sum of cosine waves function SYN_SIN usage: % [xx, tt] % fk % Xk 용 fs dur tstart xx tt syn sin (fk, Xk, fs, dur, tstart) vector of frequencies (these could be negative or positive) vector of complex amplitudes: Amp*e (j*phase) the number of samples per second for the time axis total time duration of the signal starting time (default is zero, if you make this input optional) vector of sinusoidal values vector of times, for the time axis Note: fk and Xk must be the same length. Xk (1) corresponds to frequency fk (1), Xk (2) corresponds to frequency fk (2), etc. The MATLAB syntax length (fk) returns the number of elements in the vector fk, so we do not need a separate input argument for the number of frequencies. On the other hand, the programmer (that's you) should provide error checking to make sure that the lengths of fk and Xk are the same. See help error. Finally, notice that the input fs defines the number of samples per second for the cosine generation; in other words, we are no longer constrained to using 20 samples per period. Include a copy of the MATLAB code with your lab report. 4.2.2 Default Inputs You can make the last input argument(s) take on default values if you use the nargin operator in MATLAB. For example, tstart can be made optional by including the following line of code: 4.2.3 Testing if nargin<5, tstart=0, end --default value is zero In order to use this M-file to synthesize harmonic waveforms, you must choose the entries in the frequency vector to be integer multiples of some desired fundamental frequency. Try the following test and plot the result. [xx0, tt0] syn sin([0, 100, 250], [10, 14*exp(-1*pi/3), 8-11, 10000, 0.1, 0); -Period = ? Measure the period of xx0 by hand. Then compare the period of xx0 to the periods of the three sinusoids that make up xx0, and write an explanation on the verification sheet of why the period of xx0 is longer. Instructor Verification (separate page)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 1 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning