필터 지우기
필터 지우기

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

카테고리

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