Question: Problem 2: Sampled Sinewave Ohen, engineering measurements are made using sensors that track some quantity over time. 50 an accelerometer may be used to measure
Problem 2: Sampled Sinewave Ohen, engineering measurements are made using sensors that track some quantity over time. 50 an accelerometer may be used to measure vibration vs. time or a temperature sensor is used to measure temperature over time. Often, these data are converted into digital data using analog-to- digital converters, or ADC, that capture the value of the quantity evenly spaced times Here we will assume the true signal is a sinewave of the form y(t) = Asin(2xft) where the frequency fis in units of Hz (t/sec) and the time is in units of seconds. We will also assume that we are using an ADC that grabs a new sample of data at even time intervals, starting at- and going up to some maximum time To simulate the ADXC outputs, you will write two pieces of code, a function and a script Part 1: Sampled Sine function Write a function Sampledsine whose first line is function ly, t] - SampledSine (amp, freq, dt, maxTime) Where amp refers to the amplitude A, freq refers to the frequency and dT and maxime are used to set up the timest. This function should do the following: The first lines in your function should check that the inputs make sense dit is a positive number, maxtime is a positive number, and dT is smaller than maxTime. If any of these tests fail, you should set y (empty set) and exit the function Otherwise, set up a time vector that starts at 0 and goes to maxTime, with spacing of Compute the output y at all those times using the equation above. Part 2: Simulate ADC script Write a script called SimulateADC that will call the Sampled Sine function with different values of the input variables, which we'll use to compare frequencies. Use values Amplitude of 10 . A time of 5 seconds total, with 0.1 second intervals. (After you get output from the function, make sure you did this right) 4 frequencies, 0.2, 1, 2.5, 4.5. Store these as separate vectors to make plotting easier (that is, don't use a loop here and plot within the loop) Plot the y's for all 4 frequencies in one figure (Can you plot all together or do you need subplots! If subplots, what arrangement). Make sure the 4 sets of data are easily discernable. Since we care about frequencies here, make sure you mark cach point, not just lines. Label your plots) The period of a waveform (in seconds) is 1/frequency (in Hz) or T V Answer the following questions in your code as comments a What are the periods for the 4 frequencies? b. Use this period knowledge (and dT) to explain, qualitatively, what is happening in the plots. (About a sentence for each) c. What dT would you need to make the plot with 45 Hz look right? Problem 2: Sampled Sinewave Ohen, engineering measurements are made using sensors that track some quantity over time. 50 an accelerometer may be used to measure vibration vs. time or a temperature sensor is used to measure temperature over time. Often, these data are converted into digital data using analog-to- digital converters, or ADC, that capture the value of the quantity evenly spaced times Here we will assume the true signal is a sinewave of the form y(t) = Asin(2xft) where the frequency fis in units of Hz (t/sec) and the time is in units of seconds. We will also assume that we are using an ADC that grabs a new sample of data at even time intervals, starting at- and going up to some maximum time To simulate the ADXC outputs, you will write two pieces of code, a function and a script Part 1: Sampled Sine function Write a function Sampledsine whose first line is function ly, t] - SampledSine (amp, freq, dt, maxTime) Where amp refers to the amplitude A, freq refers to the frequency and dT and maxime are used to set up the timest. This function should do the following: The first lines in your function should check that the inputs make sense dit is a positive number, maxtime is a positive number, and dT is smaller than maxTime. If any of these tests fail, you should set y (empty set) and exit the function Otherwise, set up a time vector that starts at 0 and goes to maxTime, with spacing of Compute the output y at all those times using the equation above. Part 2: Simulate ADC script Write a script called SimulateADC that will call the Sampled Sine function with different values of the input variables, which we'll use to compare frequencies. Use values Amplitude of 10 . A time of 5 seconds total, with 0.1 second intervals. (After you get output from the function, make sure you did this right) 4 frequencies, 0.2, 1, 2.5, 4.5. Store these as separate vectors to make plotting easier (that is, don't use a loop here and plot within the loop) Plot the y's for all 4 frequencies in one figure (Can you plot all together or do you need subplots! If subplots, what arrangement). Make sure the 4 sets of data are easily discernable. Since we care about frequencies here, make sure you mark cach point, not just lines. Label your plots) The period of a waveform (in seconds) is 1/frequency (in Hz) or T V Answer the following questions in your code as comments a What are the periods for the 4 frequencies? b. Use this period knowledge (and dT) to explain, qualitatively, what is happening in the plots. (About a sentence for each) c. What dT would you need to make the plot with 45 Hz look right
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
