Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Unable to read elements from the matrix in loop
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2017 年 2 月 4 日
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 件のコメント
Guillaume
2017 年 2 月 6 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!