필터 지우기
필터 지우기

Koch Square Problem : A(I): index out of bounds; value 4 out of bound 3

조회 수: 3 (최근 30일)
Mohanad Arafae
Mohanad Arafae 2016년 11월 14일
댓글: KSSV 2016년 11월 15일
Can someone please fix my error?

답변 (1개)

Walter Roberson
Walter Roberson 2016년 11월 14일
You use newpointsx(4) and newpointsy(4) before you have assigned anything to those locations. Two lines further on you use the (5) indices too.
  댓글 수: 5
Walter Roberson
Walter Roberson 2016년 11월 14일
Your code has
v=[newpointsx(4);newpointsy(4)]-[newpointsx(2);newpointsy(2)]
vprime = R*v
f=[newpointsx(5);newpointsy(5)]-[newpointsx(3);newpointsy(3)]
fprime = R*f
newpointsx(4) = vprime(1)+newpointsx(2) %Point D
newpointsy(4) = vprime(2)+newpointsy(2)
newpointsx(5) = fprime(1)+newpointsx(3) %Point F
newpointsy(5) = fprime(2)+newpointsy(3)
Notice that you use newpointsx(4) and newpointsy(4) in calculating v, but you do not assign any value to newpointsx(4) or newpointsy(4) until 5 lines later in the code.
You need to assign values to newpointsx(4), newpointsx(5), newpointsy(4), newpointsy(5) before you can use them in calculations.
KSSV
KSSV 2016년 11월 15일
@ Walter Roberson, I apologize, I have not seen all this discussion and in hurry closed the question. I shall be careful next time.

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

카테고리

Help CenterFile Exchange에서 Octave에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by