Filter löschen
Filter löschen

Im getting a 'Index exceeds matrix dimensions' error on the line indicated, don't know how to resolve.

1 Ansicht (letzte 30 Tage)
% 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;

Antworten (1)

Keerthana Chiruvolu
Keerthana Chiruvolu am 11 Mär. 2020
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.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by