you should write it as a function (in either anonymous function, function file or subfunction if your main program is also a function). Let's say you make a function file:
function [F]=my_fun(var1,var2,par1,par2,....)
F(1:x_length,1)=.....
F(x_length+1:....)=
end
Then if you want to solve for var1 and var2: f_obj=@(x)my_fun(x(1),x(2),par1,par2,...); %anonymous function fsolve(f_obj,x0)
with x0 containing two values (var1_0 and var2_0)