matlab - 使用 Matlab 查找函数使用其坐标获取顶点的索引
问题描述
我有一个包含曲面网格顶点的矩阵 50943x3。我想使用它的坐标 (x,y,z) 找到某个顶点的索引。
我尝试了 Matlab 函数 find 但它返回一个 0×1 的空矩阵。
提前致谢,
干杯
解决方案
由于浮点舍入错误,您的尝试可能不起作用。你可以在这里阅读更多关于它的信息。您可以查看eps 函数,或者仅使用以下示例:
% Your matrix
M = randn(50943 , 3);
% The coordinates you are looking for
P = [0,0,0];
% Distance between all coordinates and target point
D = sqrt(sum((M - bsxfun(@minus,M,P)).^2,2));
% Closest coordinates to target
[~ , pos] = min(D);
% Display result
disp(M(pos , :))
推荐阅读
- javascript - 在 Firebase 函数中从 Firestore 获取数据时遇到问题
- cygwin - Nutch-cygwin:错误 output.FileOutputCommitter - Mkdirs 未能创建文件
- vba - 遍历一组选定的形状时,如何对当前选择和新创建的形状进行分组?
- java - Gluon Mobile 应用程序安装成功,但当我在 android 中打开它时崩溃
- python - 遍历具有时间值并返回秒的熊猫数据框列
- php - 在 AWS Elastic beanstalk 环境中找不到类
- react-native - 在 ios react native 中找不到“React/RCTAnimationType.h”文件
- javascript - 用 reduce 代替过滤器来计算范围内的对象
- rest - 对私有 REST API 的调用返回 400 还是 500 是否重要?
- jenkins - 将来自多台机器的诱惑报告合并为一个,无需重试