How can I plot an equation to its time lag?
3 ビュー (過去 30 日間)
古いコメントを表示
I am using MATLAB to solve an economic model and I would like to plot in a graph consumption in period t+1 and consumption in period t. The equation for consumption is:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/280469/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/280470/image.png)
where
are parameters that I can choose the value but
correspond to the sequence defined above. Since I know consumption in period 0,
, I can solve for the sequence using a loop. However, I do not know how to plot consumption to its lag in a graph.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/280471/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/280472/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/280473/image.png)
Thanks for your help!!
2 件のコメント
Image Analyst
2020 年 3 月 29 日
What does "to its lag" mean? If you want to plot consumption, just use the plot() function after the loop.
回答 (1 件)
darova
2020 年 3 月 29 日
Use for loops
c(1) = w + (1-b)*(1+r)*a0 + D;
for t = 1:n-1
c(t+1) = (1+r)*(c(t)-ch)*b + ch;
end
plot(1:n,c)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!