Use vpasolve on a table

1 回表示 (過去 30 日間)
Andreas Orland
Andreas Orland 2021 年 3 月 16 日
コメント済み: Andreas Orland 2021 年 3 月 18 日
I import an Excel table that contains wealth and income values and CRRA coefficients in the rows. I would like to know
how much people should save (given their CRRA coeffiecient). I know that I need vpasolve to find the roots of the first-order
condition. s2 is the variable that I am interested in.
T = readtable('Savings.xls.xlsx');
syms s2
T.behavioralsavings2 = vpasolve( (70+s2)*(log(70+s2))^(T.crracoef)-(70+T.wealth2)*(log(70+T.wealth2))^(T.crracoef), s2)
I get the following error messages:
Error using ^ (line 344)
Matrix must be square.
Error in Untitled (line 3)
T.behavioralsavings2 = vpasolve( (70+s2)*(log(70+s2))^(T.crracoef)-(70+T.wealth2)*(log(70+T.wealth2))^(T.crracoef), s2)
I do not have the slightest idea what to do. Am I on the right path applying vpasolve on a table? Thanks!

採用された回答

darova
darova 2021 年 3 月 17 日
Try to change your code like this
T = readtable('Savings.xls.xlsx');
syms s2
for i = 1:size(T,1) % number of rows
T.behavioralsavings2(i) = vpasolve( (70+s2)*(log(70+s2))^(T.crracoef(i))-(70+T.wealth2(i))*(log(70+T.wealth2(i)))^(T.crracoef(i)), s2)
end
  1 件のコメント
Andreas Orland
Andreas Orland 2021 年 3 月 18 日
Perfect! Thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by