MATLAB 1 )The root-mean-square (rms) average is another way of calculating a mea
ID: 3807546 • Letter: M
Question
MATLAB
1 )The root-mean-square (rms) average is another way of calculating a mean for a set of numbers. The rms average of a series of numbers is the square root of the arithmetic mean of the squares of the numbers: rms average = (( (1/N)_(i=1)^Nx_i^2 ))
1. The root mean square (rms) average is another way of calculating a mean for a set of numbers. The rms average of a series of numbers is the square root of the arithmetic mean of the squares of the numbers: (1/N) rms average Write a Matlab program that will accept an arbitrary number of positive input values and calculate the rms average of the numbers. Prompt the user for the number of values to be entered, and then use a for' loop to read in the numbers, and finally calculate and display the result. Test your program by calculating the rms average of the four numbers 10, 5,2 and 5. Command Window Specify the total number of inputs: 4 Input 1th number: 10 Input 2th number: 5 Input 3th number 2 Input 4th number: 5 rms average 6.2048 2. Use vector, build-in functions, and element-yise operations to implement the solution of problem 1. The program prompts users to input an arbitrary number of inputs as a vector and calculate the rms average of the numbers. Test your program by calculating the rms average of the four numbers 10. 5. 2 and 5 Command Window Input numbers [10, 5, 2, 51 rms average 6.2048Explanation / Answer
function r = rms(inputVector, n)
squaredsum = 0
for i = 1:n
squaredsum = squaredsum + inputVector(i).^2
end
squaredsum = squaredsum/n
r = squaredsum.^(1/2)
end
n = input("Specify the total number of inputs: ")
inputVector = zeros(n, 1)
for i = 1:n
fprintf("Input %dth number: ", i)
inputVector(i) = input("")
end
fprintf("Input numbers: [%d", inputVector(1))
for i = 2:n
fprintf(", %d", inputVector(i))
end
fprintf("] ")
fprintf("rms average = %.4f ", rms(inputVector, n))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.