Can anyone please help me to understand the problem here? I keep getting the error "Index exceeds matrix dimensions".

 채택된 답변

Replace length(circles) by size(circles,1)

댓글 수: 2

changing it to size(circles,2) works. Thank you.
You index circles(i,1) so i should be at most size(circles,1)
Notice though that in your "if" you index peaks(i,2) but after that you index peaks(3,i) which switches the position of the "i" .

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Andrei Bobrov
Andrei Bobrov 2012년 12월 26일
편집: Andrei Bobrov 2012년 12월 26일
if size(circles,1) == size(peaks,1)
dc = cellfun(@(f)f(ang).*peaks(3,circles(:,1) & peaks(:,2)),{@cos,@sin},'un',0);
[xp,yp] = dc{:};
end

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2012년 12월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by