Question: function [ medianValue , meanValue ] = myArrayStats ( array 1 ) % Step 1 : Sort the array using the allowed 'sort' function sortedArray
function medianValue meanValue myArrayStatsarray Step : Sort the array using the allowed 'sort' function sortedArray sortarray; Step : Calculate the median n lengthsortedArray; if modn Odd number of elements Median is the middle value in the sorted array medianValue sortedArrayn ; else Even number of elements Median is the average of the two middle values middle sortedArrayn ; middle sortedArrayn ; medianValue middle middle; end Step : Calculate the mean using a loop total ; Initialize sum for i :n total total arrayi; end meanValue total n; Divide total by the number of elements end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
