Error while using Surface Intersection function in a loop "Subscript indices must either be real positive integers or logicals"

3 views (last 30 days)
Hi everybody, I am struggling with the last part of my Script. I attach here the error and the correlated part of the script.
Script:
for ind1=1:length(Slicesurf)
for ind2=1:(ncontour*2)
[~, intersection] = SurfaceIntersection(Slicesurf(ind1),Htot(ind2));
Infill(ind1,ind2).faces=intersection.faces;
Infill(ind1,ind2).vertices=intersection.vertices;
Infill(ind1,ind2).edges=intersection.edges;
end
end
the curious thing is that the loop goes well for a few rounds but then it stops and give me this error. ncontour and lenght(Slicesurf) are both real and positive. Slicesurf contains all surfaces parallel to xy plane and Htot contains 3D parabolas.
Error:
"Subscript indices must either be real positive integers or logicals.
Error in SurfaceIntersection>TriangleIntersection3D_Moller (line 367)
a2 = lut(sign(du)*[9; 3; 1] + 14); % calculate the key and call the look-up table
Error in SurfaceIntersection (line 218)
[intMatrix(tMsk), intSurface] = TriangleIntersection3D_Moller(...
Error in SurfaceIntersection_prova13 (line 166)
[~, intersection] = SurfaceIntersection(Slicesurf(ind1),Htot(ind2));"
can someone help me? I am going crazy with this error!
Thanks a lot!

Answers (1)

James Tursa
James Tursa on 5 Oct 2017
Edited: James Tursa on 5 Oct 2017
Often this is the result of having a variable with the same name as a MATLAB function you are using, so the variable is shadowing the MATLAB function. E.g., maybe you have inadvertently created a variable named "sign" and "du" is not an integer when you encounter sign(du).

Community Treasure Hunt

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

Start Hunting!