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

Question6 15 Marks An engineer has recorded a sound signal from a microphone, an

ID: 3885568 • Letter: Q

Question

Question6 15 Marks An engineer has recorded a sound signal from a microphone, and sampled it; these values are stored in a vector. The units of each sample is volts. The microphone was not on at all times, and, therefore, some data samples below a certain threshold are considered to not valid data samples; samples greater than or equal to the threshold are valid. The en- gineer would like to know the average voltage of the sound signal, given by, sum of valid samples/number of valid samples and the fraction of valid data samples, given by, number of valid samples/total number of samples. If the number of valid samples is 0, then the function must return 0 for both the average voltage and the fraction of valid data points Write a function, computeAverageVoltage with the following signature. function [average-voltage, frac-valid)- computeAverageVoltage(v, voltage threshold) Inputs: v - a vector that contains the values of all the voltage samples (in volts) voltage.threshold threshold voltage (in volts)

Explanation / Answer

function [average_voltage, frac_valid] = computeAverageVoltage(v, voltage_threshold)  
frac_valid = [];
for i=1:length(v)
% if it is beyond threshold
if (v(i) >= voltage_threshold)
frac_valid = [frac_valid v(i)];   
end   
end
average_voltage = mean(frac_valid);  
return
end

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