For loop, exceeded dimension error.
이전 댓글 표시
Hi, this is most certainly an easy fix on which I seem to got myself stuck.
The loop should compare elements of an array and if it finds that they are equal it shall erase that row, next it shall recompute the size of the array and redo the comparison for the next element:
for ii=1:N
if (ii>1) && (ii<N)
i3=ii+1;
for jj=i3:N
if DD(ii,1)==DD(jj,1)
DD(jj,:)=[];
[N,M]=size(DD);
end
end
end
end
I get the following error:
??? Index exceeds matrix dimensions.
Error in ==> VB_CompDin2Darray at 29
if DD(ii,1)==DD(jj,1)
A pointer would be great. Cheers.
채택된 답변
추가 답변 (1개)
Jan
2011년 7월 20일
Simple and efficient for large matrices:
[dummy, index] = unique(DD(:, 1));
DD = DD(index, :);
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!