Info

此问题已关闭。 请重新打开它进行编辑或回答。

I am having trouble with "Index exceeds matrix dimensions"

1 次查看(过去 30 天)
Hi, Just wondering if anyone can help me with "Index exceeds matrix dimensions". I have figured out that it means my code is running out of the required dimensions but don't know how to fix it? any ideas?
  1 个评论
zachary
zachary 2016-9-28
编辑:Walter Roberson 2016-10-2
its a 20x20 array and i have provided the code below
disp('Pattern Map');
for r = 1: Max_Rows
for c = 1:Max_Columns
if Classification_Map(r,c) == Classification_Map(r,c+1) && Classification_Map(r,c) == Classification_Map(r+1,c) && Classification_Map(r,c) == Classification_Map(r+1,c+1);
Pattern_Map(r,c) = Classification_Map(r,c);

回答(1 个)

Thorsten
Thorsten 2016-9-28
If you have MaxColumns, and c runs from 1:MaxColumns, you try to get c + 1, which is MaxColumns + 1, so you get the error:
MaxColumns = 20; MaxRows = 20;
Classification_Map = zeros(MaxRows, MaxColumns);
c = MaxColumns + 1;
Classification_Map(1, c)
Index exceeds matrix dimensions.
  9 个评论

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by