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!