'ReturnConditions' creates error in 'solve'

Hi! I am trying to solve the following system of equations analytically. Matlab can't solve the general case (in which phi is not specified) so I set its value to -1.
syms i1 i2 gamma phi w r
firstfoc=( (2+r)*w/(1+r) ) * ...
(gamma*i1^phi + (1-gamma)*i2^phi)^(1/phi)*gamma*i1^(phi-1)==1+r
secondfoc=((2+r)*w/(1+r) ) * ...
(gamma*i1^phi + (1-gamma)*i2^phi)^(1/phi)*(1-gamma)*i2^(phi-1)==1
firstfoc=subs(firstfoc,phi,-1)
secondfoc=subs(firstfoc,phi,-1)
[i1sol, i2sol]=solve(firstfoc, secondfoc, i1, i2)
[i1sol, i2sol]=solve(firstfoc, secondfoc, i1, i2,'ReturnConditions',true)
As you can see, the first call to "solve" returns an answer, but warns that it's parameter-dependent and advises setting 'ReturnConditions' to true. However, doing so causes a rather opaque error. What's going on here, and is there an easy way to tell over what regions in the (gamma, w, r) parameter space there is a solution?
Any help would be greatly appreciated!

 采纳的回答

Provide output variables, and outputs to return the parameters and conditions:
syms i1 i2 gamma phi w r
firstfoc=( (2+r)*w/(1+r) ) * ...
(gamma*i1^phi + (1-gamma)*i2^phi)^(1/phi)*gamma*i1^(phi-1)==1+r
firstfoc = 
secondfoc=((2+r)*w/(1+r) ) * ...
(gamma*i1^phi + (1-gamma)*i2^phi)^(1/phi)*(1-gamma)*i2^(phi-1)==1
secondfoc = 
firstfoc=subs(firstfoc,phi,-1)
firstfoc = 
secondfoc=subs(firstfoc,phi,-1)
secondfoc = 
[i1sol, i2sol]=solve(firstfoc, secondfoc, i1, i2)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
i1sol = 
i2sol = 
[isol1, isol2, parms, condx]=solve(firstfoc, secondfoc, [i1,i2], 'ReturnConditions',true)
isol1 = 
isol2 = 
parms = 
z
condx = 
.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品

版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by