Question
In this section, you will write a function called syn_sin.m that will synthesize a waveform from the vectors of frequencies and complex amplitudes. You must
In this section, you will write a function called syn_sin.m that will synthesize a waveform from the vectors of frequencies and complex amplitudes. You must write the function with one loop. Below is a template that you should base your solution on:
function [xx, tt] = syn_sin(fk, Xk, fs, dur, tstart) %{ syn_sin - Function to synthesize a sum of cosine waves. usage: [xx, tt] = syn_sin(fk, Xk, fs, dur, tstart) fk = vector of frequencies (could be negative or positive) Xk = vector of complex amplitudes: A*e^(j*phi) for each fk fs = the number of samples per second for the time axis dur = total time duration of the signal tstart = starting time (default is 0, 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.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ADD YOUR FUNCTION BODY HERE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ %
Here's a description in words: your function will take in two vectors of the same length: a vector of frequencies and a vector of phasors, along with numbers for sampling frequency fs, duration dur, and start time tstart. Adapt your code, from the one_cos function in your last lab, to now process these arguments, generate a sinusoid for each frequency and phasor in the two vectors and add them together.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started