对三维空间中的一组坐标点进行范围限制。

如题,我生成了一组空间中的三维感兴趣的坐标点,但不知道怎么对这组点的范围进行限制,比如我生成的点的坐标为(x,y,z),现在要求x的坐标为(-30,30),y的坐标范围为(-30,30),z的坐标范围为(0,5),请问怎么写呢?

 Réponse acceptée

brente
brente le 16 Mai 2023

0 votes

不用if
直接进行矩阵判断 假如num 是 N*3 的矩阵 每行是一个点的 xyz
flag=numel(:,1)>30 | numel(:,1)<-30 | numel(:,2)>30 | numel(:,2)<-30 | numel(:,3)>0 | numel(:,3)<5
得到所有不符合条件的矩阵行标记 flag
numel(flag,:)=[] 删除不合格的 就得到合格的

Plus de réponses (0)

Catégories

En savoir plus sur 矩阵和数组 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!