matlab - Algorithm to find a value that gives the minimum output for two or equations -


suppose have 2 equations 1 variable (free parameter) x , k1 , k2 constants. solve for:

f(x) + k1 = 0 & g(x) + k2 = 0 ... h(x) + kn = 0 

of course there no value of x satisfies of these equations. value of x minimizes output of each of these equations.

'solve' in matlab looks exact answer , returns error, here's example demonstrate:

syms x solution = solve(0.5*(x-k1)/sqrt(2) == 0, 0.5*(x-k2)/sqrt(2) == 0); 

you can try using unconstrained optimization method such fminsearch, example:

h=@(x) x^2; g=@(x) x^3; k1=2; k2=4; inital_guess=3;  f = @(x) sum(abs([h(x)+k1; g(x)+k2])); [x,fval]  = fminsearch(f,inital_guess) 

note represent both eq in matrix form, , minimization looking @ sum of absolute values.

for values entered value of x minmize these eq given output x = -1.5874


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -