Use vpasolve on a table
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!