You can simply define your model-function something like this:
func = @(B,x,y) B(3)*x+B(1)*exp(B(2)./y);
There is no reason to make a detour by symbolic variables.
Then you can simplify the definition of your error-function too. Perhaps something like this:
err_fcn = @(pars,M,X,Y,f) sum((M(:) - f(pars,X(:),Y(:) ) ).^2,'omitnan');
That error-function you can minimize with fminsearch:
Bbest = fminsearch(@(pars) err_fcn(pars,M,X,Y,func),B_guess)
The dynamic function-declaration, function-handle-argument and anonymous functions lets you define a rather general error-function where you send in the independent variables and the function-parameters and the function together with the variable to fit to. This is rather nifty...
HTH
Best Answer