MATLAB: How to perform operations using matrix of functions

cell arrayfunction handleshorzcatnewtonsroot finding

I'm trying to write a script that will find the intersection of two functions using a root finding method.
% Original functions set equal to zero
f1 = @(x,y) x^2-8*x+y^2-8*y-27;
f2 = @(x,y) x^2+y^2-16;
% Partial derivatives of functions
f1x = @(x) 2*x-8;
f1y = @(y) 2*y-8;
f2x = @(x) 2*x;
f2y = @(y) 2*y;
% Jacobian and functions matrices
J = [f1x f1y ; f2x f2y];
F = [f1 ; f2];
% Initial calculations
maxit = 30;
x0 = [4;4];
x_vec(1) = x0-J(x0)\f(x0);
e_vec(1) = abs(x_vec(1)-x0);
% While loop for remaining calculations
while max(abs(e_vec))>tol && it<maxit
x_vec(it+1) = x_vec(it) - J(x_vec(it))\F(x_vec(it));
e_vec(it+1) = abs(x_vec(it+1))-x_vec(it);
it = it+1;
end
I keep getting the error
Error using horzcat
Nonscalar arrays of function handles are not allowed; use cell arrays instead.
Error in Comp_HW2_4 (line 10)
J = [f1x f1y ; f2x f2y];
When I use a cell array it gives me the error
Undefined operator '/' for input arguments of type 'cell'.

Best Answer

J = [f1x f1y ; f2x f2y];
F = [f1 ; f2];
Replace those lines with
J = {f1x f1y ; f2x f2y};
F = {f1 ; f2};