matlab
CSIS 1040 Exercises for Week 8
Matlab/Octave has a built-in, compiled function called mean that you are going to code the hard way in the fourth exercise below.
1.) Draw a flowchart for an algorithm that will compute the arithmetic mean, for a given finite list X of positive numbers. Make sure you incorporate a loop!
2.) Draw a flowchart for an algorithm that will compute the geometric mean, for a given finite list X of positive numbers. Make sure you incorporate a loop!
3.) Draw a flowchart for an algorithm that will compute the harmonic mean, for a given finite list X of positive numbers. Make sure you incorporate a loop!
4.) Code your algorithms into a single function (using a for loop and no Matlab/Octave shortcuts). Name the m-file hw8 1.m. It should contain
function [a, g, h] = hw8 1(X)
as its first non-comment line. So taking input vector X, the function will return the three different means as a, g, and h.
5.) Write a script that codes Newton’s method for finding roots of a function. Prompt the user to enter a function handle, a starting guess, and a small error bound. After doing the computation (in a while loop) your code should display an approximate root for the function.