Storing values from a loop in a function in Matlab

对着背影说爱祢 提交于 2019-12-02 05:12:25

Many ways to do this, one straightforward way is to save each data point to a vector while in the loop and plot that vector after you exit your loop.

...
Ft = zeros(365,1); % Preallocate Ft as  a vector of 365 zeros
for t = 1:365
...
   Ft(t) = sum(initialstatevec.*Pt); % At index "t", store your output
...
end
plot(1:365,Ft);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!