Question: The instructions are to create a function named add_sines which would add mutiple signals into one and the hints are given as shown, we are
function [xx,tt] = add_sines(freqs, Camps, dur, tstart) XADD_SINES Synthesize a signal from sum of complex exponentials % usage: % [xx, tt) = add_sines(freqs, Camps, dur, tstart) % freqs vector of frequencies (usually none are negative) % Camps = vector of COMPLEX amplitudes % dur = total time duration of the signal % tstart = starting time % xx - vector of sinusoidal values % tt = vector of times, for the time axis % % Note: freqs and Camps must be the same length. % Camps (1) corresponds to frequency freqs(1). Camps (2) corresponds to frequency freqs(2), etc, % The tt vector should be generated with a small time increment that creates 32 samples for the shortest period, i.e., use the period corresponding to the highest frequency in the freqs vector. The MATLAB syntax length(freqs) returns the number of elements in the vector freqs, so we do not need a separate input argument for the number of frequencies. On the other hand, it is good programming practice to provide error checking to make sure that the lengths of the vectors freqs and Camps are the same. See function [xx,tt] = add_sines(freqs, Camps, dur, tstart) XADD_SINES Synthesize a signal from sum of complex exponentials % usage: % [xx, tt) = add_sines(freqs, Camps, dur, tstart) % freqs vector of frequencies (usually none are negative) % Camps = vector of COMPLEX amplitudes % dur = total time duration of the signal % tstart = starting time % xx - vector of sinusoidal values % tt = vector of times, for the time axis % % Note: freqs and Camps must be the same length. % Camps (1) corresponds to frequency freqs(1). Camps (2) corresponds to frequency freqs(2), etc, % The tt vector should be generated with a small time increment that creates 32 samples for the shortest period, i.e., use the period corresponding to the highest frequency in the freqs vector. The MATLAB syntax length(freqs) returns the number of elements in the vector freqs, so we do not need a separate input argument for the number of frequencies. On the other hand, it is good programming practice to provide error checking to make sure that the lengths of the vectors freqs and Camps are the same. See
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
