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!

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by