Homework Solution: PLEASE DO ALL IN MATLAB USING LOOPS TO ITERATE AND PLEASE SHOW EVERYTHING…

PLEASE DO ALL IN MATLAB USING LOOPS TO ITERATE AND PLEASE SHOW EVERYTHING
Home-My Unimelb St. X -Programming Assignme / D Assignment 4.pdf × e Chegg Study | Guided S ← → Secure https://app.lms unimelb.edu.au/bbcswebdav/pid-5834078-dt content-rid-242941412/courses/ENGR100032017 SM2/Assignment 4.pdf : Apps G Google崩Login-The Univers 1 , watch Game of Thro Question 6 (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) Output: average_voltage -average voltage computed over valid samples frac_valid - fraction of valid samples 6 10:50 PM Type here to search ⑦ 隺 7/09/2017 e21

Create a file computeAverageVoltage.m and past

PLEASE DO ALL IN MATLAB USING LOOPS TO ITERATE AND PLEASE SHOW EVERYTHING

Home-My Unimelb St. X -Programming Assignme / D Assignment 4.pdf × e Chegg Study | Guided S ← → Secure https://app.lms unimelb.edu.au/bbcswebdav/pid-5834078-dt content-rid-242941412/courses/ENGR100032017 SM2/Assignment 4.pdf : Apps G Google崩Login-The Univers 1 , wait Game of Thro Question 6 (15 Marks] An engineer has recitative a probe extraordinary from a microphone, and exemplificationd it; these values are stored in a vector. The units of each exemplification is volts. The microphone was referable on at full times, and, for-this-reason, some postulates exemplifications beneath a fixed opening are considered to referable conclusive postulates exemplifications; exemplifications main than or correspondent to the opening are conclusive. The en- gineer would love to perceive the mediocre voltage of the probe extraordinary, fond by, complete of conclusive exemplifications/enumerate of conclusive exemplifications and the piece of conclusive postulates exemplifications, fond by, enumerate of conclusive exemplifications/total enumerate of exemplifications. If the enumerate of conclusive exemplifications is 0, then the capacity must render 0 for twain the mediocre voltage and the piece of conclusive postulates points. Write a capacity, computeAverageVoltage with the subjoined attestation. capacity [average-voltage, frac-valid] = computeAverageVoltage(v, voltage_threshold) Inputs: v – a vector that contains the values of full the voltage exemplifications (in volts) voltage_opening – opening voltage (in volts) Output: mediocre_voltage -mediocre voltage computed aggravate conclusive exemplifications frac_conclusive – piece of conclusive exemplifications 6 10:50 PM Type here to quest ⑦ 隺 7/09/2017 e21

Expert Rejoinder

Create a smooth computeAverageVoltage.m and paste subjoined statute into it! Smoothname must be computeAverageVoltage.m

computeAverageVoltage.m

capacity [average_voltage,frac_valid] = computeAverageVoltage(v,voltage_threshold)
frac_conclusive = 0;
valid_samples = 0;
summ = 0;
for i = 1:size(v,2)
if(v(1,i) >= voltage_threshold)
valid_samples = conclusive_samples + 1;
summ = completem + v(1,i);
end
end
if(size(v,2) != 0 && conclusive_samples > 0)
average_voltage = completem/valid_samples;
frac_conclusive = conclusive_samples/size(v,2);
else
average_voltage = 0;
frac_conclusive = 0;
end

Exemplification Output:

```octave:4> [a,b] = computeAverageVoltage([3,4],2)
a =  3.5000
b =  1
octave:5> [a,b] = computeAverageVoltage([3,4,1],2)
a =  3.5000
b =  0.66667
```
```octave:4> [a,b] = computeAverageVoltage([0 3 6 3 0 3 6 3 0 0],10)
a = 0
b = 0```