Please write a MATLAB code. Will give thumbs up.

NOTE: You may not use the built-in MATLAB statistics functions to calculate the values. You are only allowed to use the sum(), length(), sort(), mod(), and sqrt() functions for calculating values. Part 1: Main Function Write the main function so that it has one input and 4 outputs. Validate the input so that the function will throw an error if the input is not a numeric vector. Once the input is validated, determine the number of output arguments and do the following: Do: Number of output arguments: Calculate the mean and standard deviation of the vector and return it as a two- element vector output Calculate the mean and standard deviation of the vector and return it as two separate output variables Calculate the mean, standard deviation, and median and return it as three separate output variables Calculate the mean, standard deviation, median, and quartiles and return them as separate output variables To perform the calculations, create 4 local functions to do it. Part 2: Local Functions Write four local functions to calculate the mean, standard deviation, median, and quartiles of a numeric vector. Your local functions should have their own function definition line, but do not need a H1 line or input validations. The standard deviation should use the formula given in this week’s slides (corrected sample). The median should return the middle value. It should sort the vector (in ascending order) and then determine if the length is an even or odd number: • If it is even, the median should return the average of the two values on either side of the middle of the vector If it is odd, the median should return the middle value The quartiles function should return a 3-element vector that represents the 25%, 50% and 75% values. The 50% value of the vector is the median of the vector. The 25% value of the vector is the median of the first half of the vector, and the 75% value is the median of the second half of the vector. • • If the length is even, the two vectors should be divided evenly at the middle values If the length is odd, the two vectors should include the middle value in each of their vectors Show transcribed image text NOTE: You may not use the built-in MATLAB statistics functions to calculate the values. You are only allowed to use the sum(), length(), sort(), mod(), and sqrt() functions for calculating values. Part 1: Main Function Write the main function so that it has one input and 4 outputs. Validate the input so that the function will throw an error if the input is not a numeric vector. Once the input is validated, determine the number of output arguments and do the following: Do: Number of output arguments: Calculate the mean and standard deviation of the vector and return it as a two- element vector output Calculate the mean and standard deviation of the vector and return it as two separate output variables Calculate the mean, standard deviation, and median and return it as three separate output variables Calculate the mean, standard deviation, median, and quartiles and return them as separate output variables To perform the calculations, create 4 local functions to do it. Part 2: Local Functions Write four local functions to calculate the mean, standard deviation, median, and quartiles of a numeric vector. Your local functions should have their own function definition line, but do not need a H1 line or input validations. The standard deviation should use the formula given in this week’s slides (corrected sample). The median should return the middle value. It should sort the vector (in ascending order) and then determine if the length is an even or odd number: • If it is even, the median should return the average of the two values on either side of the middle of the vector If it is odd, the median should return the middle value The quartiles function should return a 3-element vector that represents the 25%, 50% and 75% values. The 50% value of the vector is the median of the vector. The 25% value of the vector is the median of the first half of the vector, and the 75% value is the median of the second half of the vector. • • If the length is even, the two vectors should be divided evenly at the middle values If the length is odd, the two vectors should include the middle value in each of their vectors

## Expert Answer

Answer to NOTE: You may not use the built-in MATLAB statistics functions to calculate the values. You are only allowed to use the …