Error using solve command of symbolic toolbox

I wrote a code to get a solution for the DSGE model I am working on but the S function was empty at first (when I trying to get the solution using sectors by sector) then later I had this error (when I wrote the whole equation at a go): Error using sym>checkindex (line 2429) Index must be a positive integer or logical.
Error in sym>privformatscalar (line 2376) checkindex(x);
Error in sym>privformat (line 2360) s = privformatscalar(x);
Error in sym/subsref (line 1578) [inds{k},refs{k}] = privformat(inds{k});
Please I need a genuine help. Thank you :)

 採用された回答

Walter Roberson
Walter Roberson 2014 年 4 月 5 日

0 投票

Your expression includes k(-1) and ppb(-1) which are attempts to access arrays at index negative one.

6 件のコメント

Victor
Victor 2014 年 4 月 5 日
編集済み: Victor 2014 年 4 月 5 日
Thank you for the answer. but now, S is empty with a yellow warning sign:
'Warning: Explicit solution could not be found. > In solve at 179 ' Also get this error message when I give command: 'S.c':
error Comma separated list expansion has cell syntax for an array that is not a cell.
Error in sym/subsref (line 1578) [inds{k},refs{k}] = privformat(inds{k});
Walter Roberson
Walter Roberson 2014 年 4 月 6 日
What adjustment did you make to the formula ?
Victor
Victor 2014 年 4 月 6 日
All the variables are in a steady state now. k and ppb were typos initially. see the code please. Thank you
Victor
Victor 2014 年 4 月 6 日
no adjustments only on k(-1) to k. and ppb(-1) ditto
Walter Roberson
Walter Roberson 2014 年 4 月 6 日
編集済み: Walter Roberson 2014 年 4 月 7 日
Sometimes there just isn't a closed form solution to a problem.
When you use solve() in the form you are using, each of your numeric constants is being converted from (inherently in-exact) floating point into (exact) rational values, and then an exact solution is sought. If you want to approximate, get a numeric solution, then you need to set it up slightly differently.
Are you aware that one of your left hand sides is s-s (which would of course be 0) ?
You are attempting to solve 49 equations in 62 variables, unless some of those variables (other than coef) are being loaded with the "load" statement. You will almost never find a solution when you have more variables than equations.
Victor
Victor 2014 年 4 月 8 日
Walter, Thank you for the help. I hope you won't give up on me. I missed out on the 50th equation but I included it. I have 62 equations with if I added the equation for the (12) shocks 'epsa' etc. The equations for the shocks are AR(1) so this may not be right ( I tried but got some wrong values). The aim is to get a balanced growth path for the equation when I write them in steady state that is why I didn't add them. Please see the attached file, I made some adjustments and commented out the last 12 equations.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePhysics についてさらに検索

質問済み:

2014 年 4 月 5 日

コメント済み:

2014 年 4 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by