Question: Statistics! Yay! In testing our derivatron function, we used a bunch of statistics to compare arrays. In particular, we were trying to determine how closely

Statistics! Yay!
In testing our derivatron function, we used a bunch of statistics to compare arrays. In particular, we were trying to determine how closely our numerically-estimated derivative matched an analytically-evaluated derivative.
Let's build a function to automate that testing.
The function should take three inputs: the two arrays to be compared, and a criteria number. The criteria number is going to be a threshold for if we decide the two arrays are close enough to be considered essentially the same. The function should return a logical value - either true (logical 1) or false (logical 0), depending on the outcome.
The function needs to make sure the two input arrays are the same size, and return an output of logical false if the arrays are different sizes. A message should be printed indicating that the arrays are different sizes, as well.
Assuming the two arrays are the same size, the function should then:
take the difference between the two arrays, elementwise
get the average of those differences,
compare that average to the criteria, and:
If the average is greater than the criteria, display a message that the arrays are not sufficiently close together, and define the output of the function as a logical false.
If the average is less than or equal to the criteria, display a message that the arrays are sufficiently close together, and define the output of the function as a logical true.
Submit an .m file containing your function. The .m file should have an appropriate file name to work as a MATLAB function. You should include your name in comments within the file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!