Explicit solutions for a system of equations. [Struct]

12 views (last 30 days)
I tried to solve a system of three equations for variable k,n and c as below:
eqn1= z*a*k^(a-1)*n^(1-a)-d==h
eqn2= z*k^a*n^(1-a)-d*k==c
eqn3= r*c/(1-n)==z*(1-a)*k^a*n^(-a)
The problem is that the result shows it is a "struct," which I do not know how to see the explicit equations for k, n, and c. I can solve it by my handwriting calculation as follows:
c is just inserting k and n to the equation 2:
z*k^a*n^(1-a)-d*k==c.
What is wrong with my code, and how can I see the solutions explicitly? It happens every time I try to use Matlab, so I just use my hand calculation every time.
Below are codes and results:
clc
clear
syms z a k n d h c r
assume(z>0);
assume(a>0 & 1>a);
assume(n>0 & 1>n);
assume(k>0);
assume(c>0);
assume(d>0 & 1>d);
assume(h>0);
assume(r>0 & 1>r);
eqn1= z*a*k^(a-1)*n^(1-a)-d==h
eqn2= z*k^a*n^(1-a)-d*k==c
eqn3= r*c/(1-n)==z*(1-a)*k^a*n^(-a)
sol=solve([eqn1,eqn2,eqn3],[k,n,c], 'IgnoreAnalyticConstraints',1)
***********RESULTS************
경고: The solutions are parameterized by the symbols: u, x, y.
To include parameters and conditions in the solution, specify the 'ReturnConditions' option.
> In solve>warnIfParams (line 500)
In solve (line 356)
In NOAs (line 16)
경고: The solutions are valid under the following conditions: d + h == a*x^(a - 1)*y^(1 - a)*z & u + d*x == x^a*y^(1 - a)*z & 0 < u & 0 < x & 0 < y & y < 1
& r*u == (x^a*z*(a - 1)*(y - 1))/y^a.
To include parameters and conditions in the solution, specify the 'ReturnConditions' option.
> In solve>warnIfParams (line 507)
In solve (line 356)
In NOAs (line 16)
sol =
다음 필드를 포함한 struct:
k: [1×1 sym]
n: [1×1 sym]
c: [1×1 sym]

Answers (1)

Steven Lord
Steven Lord on 25 Mar 2017
Edited: Steven Lord on 25 Mar 2017
Note that the names of the fields of your struct array are exactly the names of the variables for which you told solve to solve. So the solution for k is sol.k and so on and so forth. If you type sol.k you'll be able to see those solutions.
  1 Comment
Deokjae Jeong
Deokjae Jeong on 25 Mar 2017
This is what I got. How can I see u, y, and x?
>> sol.k
ans =
x
>> sol.n
ans =
y
>> sol.c
ans =
u

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!