80 views (last 30 days)

I tried this but getting wrong solution

syms a b c d

eqn1 = 2.1544 == a*(5.95^b) + c*(5.95^d);

eqn2 = 1.71 == a*(6.72^b) + c*(6.72^d);

eqn3 = 1.99 == a*(6.35^b) + c*(6.35^d);

eqn4 = 1.59 == a*(6.98^b) + c*(6.98^d);

eqns = [eqn1 eqn2 eqn3 eqn4];

vars = [a b c d];

R = vpasolve(eqns,vars);

Star Strider
on 18 Jan 2021

y = [2.1544; 1.71; 1.99; 1.59];

rhs = @(a,b,c,d) [a*(5.95.^b) + c.*(5.95.^d); a.*(6.72.^b) + c.*(6.72.^d); a.*(6.35.^b) + c.*(6.35.^d); a.*(6.98.^b) + c.*(6.98.^d)];

gs = GlobalSearch;

fcn = @(b) norm(y - rhs(b(1),b(2),b(3),b(4)));

Problem = createOptimProblem('fmincon', 'x0',randn(4,1), 'objective',fcn)

B = run(gs, Problem)

fval = fcn(B)

producing (with reasonable consistency):

B =

67.619440740979044

-1.924836292732742

81.251260559584935

-43.549761874231805

and:

fval =

0.073738107681070

That is likely as good as it can get, although other values may be possible, with:

B =

46.932805349518709

-15.145390708060569

67.619902371215474

-1.924839968141592

producing approximately the same value for ‘fval’.

Note that this is not a particularly well-posed problem, so the individual parameter values will vary, and there could be a wide range of possible solutions.

Star Strider
on 19 Jan 2021

As always, my pleasure!

This sets the upper and lower bounds on the estimated parameters:

y = [2.1544; 1.71; 1.99; 1.59];

rhs = @(a,b,c,d) [a*(5.95.^b) + c.*(5.95.^d); a.*(6.72.^b) + c.*(6.72.^d); a.*(6.35.^b) + c.*(6.35.^d); a.*(6.98.^b) + c.*(6.98.^d)];

gs = GlobalSearch;

fcn = @(b) norm(y - rhs(b(1),b(2),b(3),b(4)));

Problem = createOptimProblem('fmincon', 'x0',randn(4,1), 'objective',fcn, 'ub',[Inf 0 Inf -5], 'lb',[0 -Inf 0 -Inf])

B = run(gs, Problem)

fval = fcn(B)

Change the bounds to get the result you want.

One result using that was:

B =

67.619855188755324

-1.924839592284333

41.807642742258828

-46.760550636559877

fval =

0.073738107644516

.

Star Strider
on 19 Jan 2021

As always, my pleasure!

Quite definitely, expecially since new functions continue to be introduced, and older ones are upgraded.

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

Start Hunting!
## 1 Comment

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/720380-how-can-i-solve-this-equation-in-which-variable-is-in-power#comment_1270940

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/720380-how-can-i-solve-this-equation-in-which-variable-is-in-power#comment_1270940

Sign in to comment.