Use vpasolve on a table

1 vue (au cours des 30 derniers jours)
Andreas Orland
Andreas Orland le 16 Mar 2021
Commenté : Andreas Orland le 18 Mar 2021
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!

Réponse acceptée

darova
darova le 17 Mar 2021
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 commentaire
Andreas Orland
Andreas Orland le 18 Mar 2021
Perfect! Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by