Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Document1 Word Picture Tools File Home Insert Draw Design Layout References Mail

ID: 3592586 • Letter: D

Question

Document1 Word Picture Tools File Home Insert Draw Design Layout References Mailings Review View Format Tell me what you want to do Share Find aac Replace Select Editing Cut Calibri (Body) NormaNo Spac.. Heading 1 Heading2 Title Subtitle Format Painter Clipboard Font Paragraph tyles ECE203: Introduction to MATLAB Programming HW3 130pts] In this assignment, you are to implement an automated algorithm that detects and computes the duration of tones. You have been provided a program called generate sets of tones.p. When you execute the program in MATLAB it will generate three different wav files. Note that even the provided file is a p-code but can be readily executed from the command prompt. Each wave file contains a set of random tones that are also spaced (time gapped) in a random fashion. You are to write a user defined function called detect tones0. The input arguments to the function are te array that contains the tone (the one that you will obtain via audioread), the sampling frequency (a scalar variable that will also be imported in your workspace using audioread) and another scalar input argument that will give options to the user (for a total of three input arguments). The function is to return an aray that contains the duration in seconds of the different tones. Start by writing a program called run detect tones.m. Read in one of the set of tones. Make sure to import the sampling rate (critical for plotting against time and to properly sound the tonc). You may plot and sound the set of tones using soundsc) to have a better feel for the problem at hand. Using your function, you are to determine the duration of cach tone. That is, you are device a scheme to segment each tone and compute its duration. This is closely related to the other audio assignment only here the process is automated. Hint: once you come up with the scheme of determining the number of samples of each tone, i is just a matter of utilizing the sampling frequency fed to the function to compute its duration. The last scalar input argument can be logical, where, in one case, the function is to return the duration of each tone only (an array comprised of the time durations) In the other case, in addition to returming the during of each tone, the function ought to plot each waveform corresponding to a tone against time and indicate its duration onto the plot via text or title). Use an indefinite pause to allow the user to flip through the various tones upon the press of any key. In other words, pressing any key will plot the and sound the next tone/waveform and so on. I will give a demo (one way of doing it) in class to better illustrate what is expected. Now repeat this for the otheT two sets of tones (i.e., reading them in MATLAB and processing them with your user defined function to successfully determine the duration of the new sets of tones). In summary you are to cal the user defined function (detect tones)) within the parent program (run_detect tones) for a total of three instances since the provided function will generate a total of 3 sets of random tones, Page 1 of 1 owords + 100% 2:00 PM 10/15/2017

Explanation / Answer

Starter code:

import matplotlib.pyplot as plt
import math as m
import random as rand

# This code generates the transmitted and received signals.
# x are the values (in radians) at which the transmitted sin function was evaluated
# (used for the x-coordiantes when plotting)
# y is the list of amplitude values in the transmitted signal
# y_noisy is the received signal corrupted by random noise
#
# DO NOT EDIT THIS CODE!

x = [ d * m.pi / 180 for d in range(360*3)]
y = [m.sin(k) for k in x ]
y_noisy = [m.sin(k) + rand.gauss(0, .1) for k in x]


# Part (a):
# Write your function for moving average filtering here. See the assignment description
# for details.

# part (b):
# write a function call here to filter y_noisy with a filter of radius 9 and obtain the filtered signal.

# part (c):
# Now write code to plot the noisy signal and the filtered signal in separate figure windows.
# Note that because a new noisy signal is generated by adding random noise each time the function
# is run, the noisy and filtered signals will look slightly different each time you run the program.
# Try to make the figures look as close as possible to the figures in the assignment description.
# The functions from matplotlib.pyplot that may be useful for this are as follows:
#
# figure(), plot(), show(), xlim(), ylim(), xlabel(), ylabel(), title()

# You need to call plt.figure() once for EACH figure you prepare. Uncomment this line when you are ready
#plt.figure()

# PLOT THE ORIGINAL, NOISY SIGNAL HERE


#plt.figure()

# PLOT THE SMOOTHED SIGNAL HER

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote