Im getting a 'Index exceeds matrix dimensions' error on the line indicated, don't know how to resolve.
1 次查看(过去 30 天)
显示 更早的评论
% solve ode
[SEIRS_data] = ode23(@(time,SEIRS) fSEIRSdot(time, m, ns, params, SEIRS),mtimes,SEIRS_init);
% calculate attack rates in each patch
daily_incidence = zeros(size(SEIRS_data,1),m);
for i=1:m
daily_incidence(:,i) = SEIRS_data(1:end,cCUM(i)) - [0 ; (SEIRS_data(1:end-1,cCUM(i)))]; %error on this line
end
AR = zeros(m,1);
AR = SEIRS_data(end,cCUM(:))./params.N;
0 个评论
回答(1 个)
Keerthana Chiruvolu
2020-3-11
Hi,
This error occurs when you refer to a nonexistent element of an array.
Set the breakpoints, run the file. Stop execution on the line where the error occurs. Verify that the size of the array which you are referring to is large enough so that the index you are using falls before the index of the last element of the array. One way to do this is to check the Workspace Browser. Verify that the variable is correctly created at each of the previous lines, starting with the most recent, where it appeared on the left side of an assignment statement.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!