Question: I am trying to write a function that calculates the average of a sequence of numbers in an array. It should take in an input
I am trying to write a function that calculates the average of a sequence of numbers in an array. It should take in an input array and prints out the average with with only two place values after decimal.
If I type these into the Command window individually I get the write answer but I want to creat a function to allow input and output answer in the right decimal form.
A = [2, 4, 5, 6, 6, 6];
ANSWER = mean (A);
fprintf('%.2f',ANSWER)
I get the following answer of 4.83. This is write but I am entering each line individually.
Example 1: input array is [2 4 5 6 6 6], should ouptut 4.83
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
