필터 지우기
필터 지우기

How to expand symbolic exponential numerator to reduce fraction

조회 수: 2 (최근 30일)
Alena
Alena 2023년 8월 3일
답변: Paul 2023년 8월 3일
I'm trying to write code to solve some macroeconomic models and I'm running into some issues getting MATLAB to give me my results in simplified form. I want the y_t equation only in terms of A_t and k_t, since L_t should cancel out. MATLAB won't seem to let me distribute the exponent and reduce the fraction unless there is a command I don't know.
Here is my code:
And here is the current output:
What I want is A_t k_t^(alpha). How do I get MATLAB to distribute the exponent?

채택된 답변

Paul
Paul 2023년 8월 3일
syms Y_t A_t K_t alpha L_t k_t w_t y_t
Y_t = A_t*K_t^alpha*L_t^(1-alpha)
Y_t = 
lil_y = y_t == Y_t/L_t
lil_y = 
labor_eqn = L_t == solve(lil_y, L_t,"Real",true)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
labor_eqn = 
y_t = solve(labor_eqn, y_t, "Real", true)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
y_t = 
k_eqn = K_t/L_t == k_t
k_eqn = 
K_t = solve(k_eqn, K_t, "Real", true)
K_t = 
y_t = subs(y_t)
y_t = 
Use simplify with the additional name/value pair
simplify(y_t,'IgnoreAnalyticConstraints',true)
ans = 
Consider checking into those warnings to make sure the conditions for the solution apply to this problem. Also, it might be beneficial to add appropriate assumptions to the variables. For example, specfying all the variables as positive (if it makes sense to do so) cleans up the warnings and mitigates the need for IgnoreAnalyticConstraints.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by