Index exceeds matrix dimensions when doing simulation

Hi all,
I am a fresh Matlab user and I am running the following codes.I want to simulate the data with different functions according to different States,but I have the problem of Index exceeds matrix dimensions. Please let me know how I should solve this problem.
Thank you so much! Edwin
for j=2:nr;
if States(j,1)==1;
yvar(j,2:9)=yvar(j-1,:)*Coeff.S_Param{1,1}+rr{1,1}(j,:);
end
if States(j,2)==1;
yvar(j,2:9)=yvar(j-1,:)*Coeff.S_Param{1,2}+rr{1,2}(j,:);
end
if States(j,3)==1;
yvar(j,2:9)=yvar(j-1,:)*Coeff.S_Param{1,3}+rr{1,3}(j,:);
end
if States(j,4)==1;
yvar(j,2:9)=yvar(j-1,:)*Coeff.S_Param{1,2}+rr{1,4}(j,:);
end
end

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 8 月 22 日
編集済み: Azzi Abdelmalek 2015 年 8 月 22 日

0 投票

Check the sizes of your variables, and don't exceed these dimensions. For example if your matrix A is 4x3, you can't write A(5,1)

1 件のコメント

Xu Bin
Xu Bin 2015 年 8 月 22 日
Thank you.
I found another mistake according to what you said.
Cheers, Edwin

この質問は閉じられています。

質問済み:

2015 年 8 月 22 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by