Solving three simultaneous equations for analytical solution

조회 수: 3 (최근 30일)
Teck Lim
Teck Lim 2020년 3월 16일
댓글: Teck Lim 2020년 3월 16일
Hi there,
I am trying to solve for k_t+1, tau_t, l^t-1_2 in terms all other parameters that are taken to be given. You can assume that w(h_t)=exp(bh_t). I have tried executing this code:
syms k2 k1 R B s h a l2 l1 t1 t2 b d
[solk2,solt1,soll2]=solve(k2==(BR(exp(bh)(1-l2-a)-t1)-t2)/(BR+R),t1==(d(exp(bh)(1-l2-a)-k2)-Rk1)/(1+d),l2==(s(exp(bh)(1-a)-k2-t1))/(exp(bh)+sexp(bh)))
I am getting the error message Indexing with parentheses '()' must appear as the last operation of a valid indexing expression.
What should I change in the code to run it properly?

채택된 답변

Stephan
Stephan 2020년 3월 16일
Keep it short and simple + use "*" for multiplication operations:
syms k2 k1 Rk1 R BR s h a l2 l1 t1 t2 bh d
eq(1) = k2==(BR*(exp(bh)*(1-l2-a)-t1)-t2)/(BR+R);
eq(2) = t1==(d*(exp(bh)*(1-l2-a)-k2)-Rk1)/(1+d);
eq(3) = l2==(s*(exp(bh)*(1-a)-k2-t1))/(exp(bh)+s*exp(bh));
vars = [k2, t1, l2]
[solk2,solt1,soll2]=solve(eq,vars)
Im not sure what you want to do with this code, because the solution for k2, t1 and l2 are already there in the equations.
  댓글 수: 4
Stephan
Stephan 2020년 3월 16일
You might want to use subs.
Teck Lim
Teck Lim 2020년 3월 16일
Alright, thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by