Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Unable to read elements from the matrix in loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
For the below code, I'm unable to read the element from the matrix intr in the loop. For example, for the line intr(2,1), I get an error as follows "Index exceeds matrix dimensions.". Can someone help me with this one.
for i = 1:M
Q1 = vertsTransformed(i,:);
Q2 = Q1 + vn(i, :);
line = createLine3d(Q1, Q2);
[intr, pos, ind] = intersectLineMesh3d(line, modelskin.vertices, modelskin.faces);
d = intr(2:end, 1:3);
X = [Q1; intr(2:end, 1:end)];
intr(2,1)
end
Thanks!!
0 Kommentare
Antworten (1)
Walter Roberson
am 4 Feb. 2017
intersectLineMesh3d is going to return an empty matrix if there are no intersection points (or if it is not able to find them.) Or it could return a single point, if that is appropriate. The (2:end,1:3) indexing is not going to be bothered in that case: it would simply return the empty matrix since 2:end would be empty in such a case. But intr(2,1) assumes that there are definitely at least 2 points.
2 Kommentare
Guillaume
am 6 Feb. 2017
If you get "Index exceeds matrix dimensions." at intr(2,1) then you did not get 2 points from intersectLineMesh3d regardless of what your wishes are.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!