% Specify function to find root of
% Function of one argument defined elsewhere:
f = @parabola;
% Anonymous binding of parameterized function:
%f = @(x) quadratic(x, 1, 0, -9);

% Find root
x0 = fzero(f, 1);
fprintf('Root found at x = %g\n', x0);

% Plot function and root
xs = linspace(0, 2*x0, 100);
ys = f(xs);
plot(xs, ys)
hold on
plot(x0, 0, 'o')
xlabel('x'); ylabel('y'); title('Found root')
hold off

% Function to find root of (local function)
function y = parabola(x)
y = x.^2 - 9;
end

% Parameterized function to find root of (local function)
function y = quadratic(x, a, b, c)
y = a*x.^2 + b*x + c;
end