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;

回答(1 个)

Keerthana Chiruvolu
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.

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by