% Problem4b maxGrad = 0; % steepest gradient found so far elevL = 0; % left neighbor of steepest gradient so far elevR = 0; % right neighbor of steepest gradient so far current = input('Enter elev: ') % current elevation value previous = current; % previous elevation value gradient = previous-current; % gradient between current and previous elevs. % Process all elevations and find maximum gradient while current >=0 % stop loop for negative values % If computed gradient greater than maxGradient, % update $maxGradient$, $elevL$, $elevR$ gradient = abs(current - previous); if gradient > maxGrad maxGrad = gradient; elevL = previous; elevR = current; end % Update previous and read next input (current) previous = current; current = input('enter elev: ') end % Output results if maxGrad == 0 disp(['Only one elevation entered or all elevations are equal']) else disp(['Steepest gradient occurs between elevations '... num2str(elevL) ' and ' num2str(elevR) ]) end