I want to solve an empirical equation that includes sinus and cosinus and find the coefficients of the equation.

4 views (last 30 days)
I have and equation as below. I am trying to solve this equation with curvefit toolbox, but sometimes it does not give good results.
H= H0*q*(a*(1-exp(y^b))+c*y^d+e*cos(y*w)+g*cos(w*x)+h*sin(w*x))
H is the solar radiation, H0 is extraterrestrial radiation. y is the ratio between atmospheric transmittance and relative humidity. x is the ratio between temperature and maximum minimum temperature differences.
I have 3082 lines H, H0, x and y data in Excel format.
I want to find q, a, b, c, d, e, g, h and w empirical coefficients.
I share my Excel file.
y is (100* τ)/RH (metot 1), x is Kelvin in Excel file and H and H0 are given in Excel.
I am very new in MATLAB.
  11 Comments
Walter Roberson
Walter Roberson on 10 Oct 2016
I used private code that is still under development.
It looks like I might accidentally have fitted only a few data points. I will need to re-test.
Walter Roberson
Walter Roberson on 10 Oct 2016
For sure I accidentally tested with only a few data points. The memory requirements for the full dataset are huge; I could never have fit them with my existing program. I will keep testing.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 10 Oct 2016
If you examine your formula
H= H0*q*(a*(1-exp(y^b))+c*y^d+e*cos(y*w)+g*cos(w*x)+h*sin(w*x))
and divide both sides by H0*q you get
H / H0 / q = a*(1-exp(y^b))+c*y^d+e*cos(y*w)+g*cos(w*x)+h*sin(w*x)
Therefore you can reduce your inputs by 1, from H and H0 individually to H ./ H0 .
It also appears to me that you could generate arbitrary values for the parameters other than q, calculate a sum-of-squares of that, and a sum-of-squares of H ./ H0, and then set q to the ratio of the two, and that should be an excellent fit. It is possible, though, that I am misunderstanding some mathematics here (I haven't had any chocolate yet today, so my thought processes are a bit slow!)
  3 Comments
Walter Roberson
Walter Roberson on 10 Oct 2016
If I set
z = H./H0
and then I use cftool, custom equation
q*(a*(1-exp(y^b))+c*y^d+e*cos(y*w)+g*cos(w*x)+h*sin(w*x))
and I set Fit Options to MaxFunEvals of 10000 and Iters of 4000, then it converges to
General model:
f(x,y) = q*(a*(1-exp(y^b))+c*y^d+e*cos(y*w)+g*cos(w*x)+h*sin(w*x))
Coefficients (with 95% confidence bounds):
a = 0.0658 (-8.835e+04, 8.835e+04)
b = 0.6595 (-0.8893, 2.208)
c = 0.5135 (-6.895e+05, 6.895e+05)
d = 0.1803 (-0.2375, 0.598)
e = -0.1876 (-2.52e+05, 2.52e+05)
g = 0.007358 (-9880, 9880)
h = -0.0005033 (-675.8, 675.8)
q = 2.641 (-3.546e+06, 3.546e+06)
w = 0.34 (0.3298, 0.3502)
Goodness of fit:
SSE: 40.73
R-square: 0.556
Adjusted R-square: 0.5548
RMSE: 0.1152
Can Ekici
Can Ekici on 11 Oct 2016
Is the curvefit toolbox suitable to solve this equation? If I change the iteration number and mxfunevals to 10000000 then the values of a,b,c... are changing.

Sign in to comment.

Categories

Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!