Use vpasolve on a table
1 view (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
darova
on 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
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!