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

Hi, can anyone help me with this MatLAb code? You are to help analyze the output

ID: 3828156 • Letter: H

Question

Hi, can anyone help me with this MatLAb code?

You are to help analyze the output voltage of a microphone. Assume that the voltages were recorded at discreet time intervals. However because the microphone was not always turned on, voltages corresponding to “noise” generated from the measuring equipment will be recorded during the intervals the microphone was turned off. Prompt the user to enter the voltages recorded in an array. Prompt the user to enter the threshold voltage below which the voltage is considered noise. Create a loop to count the number of valid voltage measurements (those above the threshold) and determine the average of the valid voltage measurements. After the loop is completed, output the number of valid measurements and the average of the valid measurements in one statement. In another statement, output the total number of measurements recorded and the percentage of invalid measurements due to “noise”.

Explanation / Answer

voltage=input("enter volatages in array format i.e [v1,v2,....] :");
threshold=input("enter threshold volatge: ");


validaverage=0;
validsum=0;
validcount=0;
invalidcount=0;
totalmeasurements=size(voltage,2);


for i=0:totalmeasurements

if(voltage(i)>threshold)
validcount=validcount+1;
validsum=validsum+voltage(i);

else
invalidcount=invalidcount+1;
end
end

validavearge=validsum/validcount;

invalidpercentage= (invalidcount/totalmeasurements)*100;


fprintf('validcount: %f validaverage: %f',validcount,validaverage);
fprintf('Totalmeasurments: %d invalidpercentage: %f',totalmeasurements,invalidpercentage );

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