In general you can use fmincon to do that. The idea is to define a function that takes both f(x) and g(x) in to account.
Lets do that.
function error2 = myFunction(betas,x)
lambda=0.5;
error2=0;
a=betas(1,1);
b=betas(2,1);
x1=x(:,1); %Assuming that both datasets have the same size. If they are not you can adjust it
y1=x(:,2);
x2=x(:,3);
y2=x(:,4);
n=size(x,1);
for i=1:n
f1=a*exp(x1(i,1))+b;
f2=atan(b*x2(i,1)/a);
error2=error2+lambda*(y1(i,1)-f1)^2 + (1-lambda)*(y2(i,1)-f2)^2;
end
Note that in "betas" I am keeping the parameters and "x" I am keeping the data. I had to introduce a new variable "lambda" in order to weight both functions f and g. This is good because varying lambda you are able to see how one of the functions affected the estimations of the other. You can actually start with lambda=0 and run several times this routine for values such as 0.1, 0.2,...,1.
Now you have to call this function using fmincon.
clear all
close all
% Here you have to create your data x: Remember the structure I used for x=[x1,y1,x2,y2]
x1=
y1=
x2=
y2=
x=[x1,y1,x2,y2];
% you need to initiate the values of your parameters beta
a0=
b0=
beta0(1,1)=a0;
beta0(2,1)=b0;
beta = fmincon(@(beta)myFunction(beta,x), beta0);
This must work!