Calibrating a non-linear array in MATLAB using 2 variables

Hello, Currently, I am trying to optimize the following equation:
function fcpred = bup(x)
load calset
c1 = x(1);
c2 = x(2);
fcpred = 100./(1+exp(((c1.*(-2*cprime))+(c2.*cprime.*ln100d))));
end
And claset contains obs, ln100d and cprime 44*1 arrays. Subjected to the contraint:
obs - fcpred = 0
and wish to minimize COV of the above. I have tried:
[x,fval] = fmincon(@bup,[0 0],[],[],[],[],[],[],@opt)
Where [opt]:
function [c, ceq]=opt(x)
load calset_LC
ceq = obs - fcpred
c = []
end
But to the error requesting that the supplied function should return a scalar value. Have I used the wrong function? or should I look to solve it as a system instead?

回答 (1 件)

Matt J
Matt J 2017 年 7 月 11 日
編集済み: Matt J 2017 年 7 月 11 日

0 投票

I have the impression that like you are trying to solve
100./(1+exp(((c1.*(-2*cprime))+(c2.*cprime.*ln100d)))) - obs = 0;
If so, and if c1 and c2 are unconstrained, you would probably want to use fsolve,
[x,fval] = fsolve(@(x) bup(x) - obs, x0 )
The initial guess x0 can probably be obtained by rearranging this as a linear equation
log(100./obs-1) = c1.*(-2*cprime) + c2.*cprime.*ln100d
and solving. Or, maybe the linear solution is already good enough for your purposes.

2 件のコメント

Iliya Nemtsov
Iliya Nemtsov 2017 年 7 月 11 日
Hi Matt,
Thank you for your suggestion but I am trying to eliminate the residual of the result, hence:
obs - fcpred = 0
c1 and c2 values are calibration factors and yes they are unconstrained.
But using the same logic I had is set up in Excel Solver and C1 and C2 should yield approximately .5236 and 0.1404 respectively.
This code is a stepping stone as I am going to utilize it in a Jack Knife Procedure (custom code) utilizing n-2 sets.
Matt J
Matt J 2017 年 7 月 12 日
Thank you for your suggestion but I am trying to eliminate the residual of the result, hence: obs - fcpred = 0
I don't see how you can do that. You have 44 residuals to drive to zero, but only 2 degrees of freedom (c1 and c2).

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSystems of Nonlinear Equations についてさらに検索

製品

質問済み:

2017 年 7 月 11 日

コメント済み:

2017 年 7 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by