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 응 usage: [xx, tt] = syn_sin (fk, Xk, fs, dur, tstart) Function to synthesize a sum of cosine waves [xx, tt] = syn_sin (fk, Xk, fs, dur, tstart) fk = vector of frequencies (these could be negative or positive) vector of complex amplitudes: Amp*e^(j*phase) 응 Xk 응 fs = the number of samples per second for the time axis total time duration of the signal dur = .. tstart = starting time (default is zero, if you make this input optional) xx = vector of sinusoidal values 응 tt 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.

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
icon
Related questions
Question

this will be a code in matlab, thank you

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
응
usage:
[xx, tt] =
syn_sin (fk, Xk, fs, dur, tstart)
Function to synthesize a sum of cosine waves
[xx, tt] = syn_sin (fk, Xk, fs, dur, tstart)
fk = vector of frequencies
(these could be negative or positive)
vector of complex amplitudes: Amp*e^(j*phase)
응
Xk
응
fs =
the number of samples per second for the time axis
total time duration of the signal
dur =
.. tstart = starting time (default is zero, if you make this input optional)
xx = vector of sinusoidal values
응
tt 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.
Transcribed Image Text: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 응 usage: [xx, tt] = syn_sin (fk, Xk, fs, dur, tstart) Function to synthesize a sum of cosine waves [xx, tt] = syn_sin (fk, Xk, fs, dur, tstart) fk = vector of frequencies (these could be negative or positive) vector of complex amplitudes: Amp*e^(j*phase) 응 Xk 응 fs = the number of samples per second for the time axis total time duration of the signal dur = .. tstart = starting time (default is zero, if you make this input optional) xx = vector of sinusoidal values 응 tt 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.
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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education