Clear Filters
Clear Filters

index exceeds matrix dimension

1 view (last 30 days)
sbei arafet
sbei arafet on 21 Mar 2016
Edited: Adam on 21 Mar 2016
Hi i tried this code but it says that index exceeds matrix dimensoin
fgx=fg(:,1);% Foreground or object pixels
fgy=fg(:,2);
for i = 1:size(fgx,1)
obj_pixels(i)=im(fgx(i),fgy(i));% Extract values of foreground pixels
end
sizes:
size(fgx)=10941x1
size(fgy)=10941x1
size(fgx,1)=10941
i=129
i don't know why i is stoped only on 129
thanks in advance
  1 Comment
Adam
Adam on 21 Mar 2016
Edited: Adam on 21 Mar 2016
Without being able to run the code I suspect that the index that is exceeding the matrix dimension is not 'i' as an index to fgx or fgy, but the result of fgx(i) or fgy(i) exceeds the dimensions of 'im' when you try to index into it using these.
What is the size of 'im' and what are the values of fgx(129) and fgy(129)?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!