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

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

ID: 3873160 • Letter: P

Question

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 GoogleLogin-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

Explanation / Answer

Create a file computeAverageVoltage.m and paste following code into it! Filename must be computeAverageVoltage.m

computeAverageVoltage.m

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

Sample Output:

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