Two functions optimization and curve fitting
1 view (last 30 days)
Show older comments
Hi, I have these two functions:
sigma_11_fun = @(a, lambda) (-1/lambda(2)^2) * (2*a(1) + 4*a(2)*(lambda(1)^2 + lambda(2)^2 + (1/(lambda(1)^2 * lambda(2)^2))-3)) + 2*a(1)*lambda(1)^2 + 4*a(2)*lambda(1)^2*(lambda(1)^2 + lambda(2)^2 + (1/(lambda(1)^2 * lambda(2)^2))-3) + 2*lambda(1)^2*a(3)*(lambda(1)^2-1)*exp(a(4)*(lambda(1)^2-1));
sigma_22_fun = @(a, lambda) (-1/lambda(1)^2) * (2*a(1) + 4*a(2)*(lambda(1)^2 + lambda(2)^2 + (1/(lambda(1)^2 * lambda(2)^2))-3)) + 2*a(1)*lambda(2)^2 + 4*a(2)*lambda(2)^2*(lambda(1)^2 + lambda(2)^2 + (1/(lambda(1)^2 * lambda(2)^2))-3);
As you can see, sigma_11_fun is a functions of lambda_1, lambda_2, a(1), a(2), a(3) and a(4) while sigma_22_fun is a function of lambda_1, lambda_2, a(1) and a(2).
I have the data for sigma_11, sigma_22, lambda_1 and lambda_2. Now using this data and functions above, I want to do a curve-fitting to obtain a(1), a(2), a(3) and a(4) constant parameters and of course, a(1) and a(2) which are mutual in both functions should have one value which is similar for both functions.
I defined this error function for the optimization process:
err_fun = @(a, lambda) (sigma_11 - sigma_11_fun(a, lambda)).^2 + (sigma_22 - sigma_22_fun(a, lambda)).^2;
I tried both fmincon and ga functions to do the optimization using the defined error function and initial guess of "a0 = [1, 1, 1, 1]" but results are completly wrong and not even close. I tried to increase maximum generation etc, but nothing helped.
Can someone please help with this?
Thanks in advance.
Diagram of data
0 Comments
Answers (1)
Matt J
on 18 Dec 2023
Edited: Matt J
on 18 Dec 2023
Either you have a bad initial guess, or a bad model. If the latter is true, we cannot help you. If the former is true, it may help to use fminspleas, downloadable from,
Your prediction function appears to be linear in all of the unknowns except a(4). Therefore, fminspleas would only require an initial guess for a(4).
0 Comments
See Also
Categories
Find more on Genetic Algorithm 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!