4.2.1 Write the Function M-file x(t) = N RXkej 2лfkl k=1 N x(t) = Σ Ak cos(2π fkt + k) k=1 (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: function %SYN_SIN [xx, tt] = syn_sin (fk, Xk, fs, dur, tstart) Function to synthesize a sum of cosine waves ge usage: = syn_sin (fk, Xk, fs, dur, tstart) (these could be negative or positive) fk = vector of frequencies [xx, tt] 응 op g op Xk = vector of complex amplitudes: Amp*e (j*phase) fs dur the number of samples per second for the time axis total time duration of the signal tstart = starting time (default is zero, if you make this input optional) xx = vector of sinusoidal values g tt = vector of times, for the time axis. op op Note: fk and Xk must be the same length. op op 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.1 Write the Function M-file x(t) = N RXkej 2лfkl k=1 N x(t) = Σ Ak cos(2π fkt + k) k=1 (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: function %SYN_SIN [xx, tt] = syn_sin (fk, Xk, fs, dur, tstart) Function to synthesize a sum of cosine waves ge usage: = syn_sin (fk, Xk, fs, dur, tstart) (these could be negative or positive) fk = vector of frequencies [xx, tt] 응 op g op Xk = vector of complex amplitudes: Amp*e (j*phase) fs dur the number of samples per second for the time axis total time duration of the signal tstart = starting time (default is zero, if you make this input optional) xx = vector of sinusoidal values g tt = vector of times, for the time axis. op op Note: fk and Xk must be the same length. op op 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.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
please help. this will be a matlab code
![4.2.1
Write the Function M-file
x(t) =
N
RXkej 2лfkl
k=1
N
x(t) =
Σ Ak cos(2π fkt + k)
k=1
(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:
function
%SYN_SIN
[xx, tt]
=
syn_sin (fk, Xk, fs, dur, tstart)
Function to synthesize a sum of cosine waves
ge usage:
=
syn_sin (fk, Xk, fs, dur, tstart)
(these could be negative or positive)
fk = vector of frequencies
[xx, tt]
응
op
g
op
Xk = vector of complex amplitudes: Amp*e (j*phase)
fs
dur
the number of samples per second for the time axis
total time duration of the signal
tstart = starting time (default is zero, if you make this input optional)
xx = vector of sinusoidal values
g
tt = vector of times, for the time axis.
op
op
Note: fk and Xk must be the same length.
op
op
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5b55a0fb-5dff-4587-97c0-c3ec381e9c7e%2Fe6f5609a-f74b-4f06-967c-d897f2e66ae7%2F6afqu45_processed.png&w=3840&q=75)
Transcribed Image Text:4.2.1
Write the Function M-file
x(t) =
N
RXkej 2лfkl
k=1
N
x(t) =
Σ Ak cos(2π fkt + k)
k=1
(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:
function
%SYN_SIN
[xx, tt]
=
syn_sin (fk, Xk, fs, dur, tstart)
Function to synthesize a sum of cosine waves
ge usage:
=
syn_sin (fk, Xk, fs, dur, tstart)
(these could be negative or positive)
fk = vector of frequencies
[xx, tt]
응
op
g
op
Xk = vector of complex amplitudes: Amp*e (j*phase)
fs
dur
the number of samples per second for the time axis
total time duration of the signal
tstart = starting time (default is zero, if you make this input optional)
xx = vector of sinusoidal values
g
tt = vector of times, for the time axis.
op
op
Note: fk and Xk must be the same length.
op
op
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.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 1 steps

Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education