MATLAB: How to parametrize two parameters in an equation

parametrize

I have observed relative humidity and a statistical method to estimate RH. The statistical method uses two different parameters and I would like to use the observations to parametrize the two parameters (the parameters are supposed to be around 2.1 for a and 0.130 for ab).
What I have done so far is;
best_total_dist=10000000000;
best_a=100;
best_ab=100;
hum=log(rh); % rh is observed relative humidity
for a=0:0.01:2.3
for ab=0:0.001:0.0150
estrh=10.^(a-(ab.*t)); % statistical method to estimate relative humidity
difference=estrh-hum;
difference_sq=difference.^2;
sum_difference=sum(difference_sq);
if sum_difference<best_total_dist
best_total_dist=sum_difference;
best_a=a;
best_ab=ab;
end
end
end
Where am I going wrong?

Best Answer

According to your code, the model for 'rh' (not log(rh)) is going to be
rh = exp(10.^(a-(ab.*t)))
That's a doubtful looking model to me. At t=0, it means that rh=4.7254e+54.
If I assume that you really meant,
log(rh)= a-(ab.*t)
then you could find the least squares solution by
x=[ones(size(t)), -t]\log(rh);
a=x(1);
ab=x(2);
Related Question