HELP: Index in position 2 is invalid. Array indices must be positive integers or logical values.

1 view (last 30 days)
I got this error in my code file: "Index in position 2 is invalid. Array indices must be positive integers or logical values."
It refers to these lines:
Index in position 2 is invalid. Array indices must be positive integers or logical values.
Error in straighten>getInterpolatedValue (line 65)
I(1,1) = IM(x(1),y(1))*(1-x(3))*(1-y(3));
Error in straighten (line 50)
IM2(ct,ct2) = getInterpolatedValue(IM,xStart,yStart);
Error in test7 (line 68)
IM2 = straighten(IM,[x;y]',450);
I've tried checking if I entered the equation wrong or if I have to save certain values as integers but nothing seems to work.I have attached 2 files of my code. What should I do to fix this error? Any advice would be greatly appreciated.

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 20 Mar 2022
Your fcn file straighten.m that contains one crucial mistake, i.e.:
The command in it on line 10 has a conflict:
IM2(:,:,ct)=straighten(IM(:,:,ct),pts,width); that must be fixed.
Note that the same function within the same function file can't called.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!