Asked by Jatin Arora
on 23 Nov 2012

Hello Everyone ,

I have a set of points which are stored in n*3 MATRIX. These are points from a sensor and at the starting and ending there is a lot of disturbance in the signal and I get points which are very close to each other. I have to remove these points. So I check the distance between points starting from the first point and whenever I get a point outside a user input radius I break the loop.

The problem is I want to make a new array of dimensions m*3 in which I have the first point of my Input array then next (x) points are removed and then i get the remaining points.

Can someone help me with this?

*No products are associated with this question.*

Answer by Jan Simon
on 23 Nov 2012

I'm not sure if I understood the concept of your "points" correctly. But perhaops you want something like this:

X = cumsum(rand(1000, 3)); % Test data keep = false(1000, 1); radius = 0.7; radius_2 = radius ^ 2; % Avoid the expensive SQRT

orig = X(1, :); keep(1) = true; for ii = 2:1000 dist_2 = sum((X(ii, :) - orig) .^ 2); if dist_2 > radius_2 keep(ii) = true; orig = X(ii, :); end end CleanedX = X(keep, :);

Image Analyst
on 24 Nov 2012

I'd think you'd do

if dist_2 <= radius_2

because he wants to keep only those *within* that distance of the first point, not keep points *farther away*.

Image Analyst
on 25 Nov 2012

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 4 Comments

## Azzi Abdelmalek (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/54597#comment_112931

What if the number of removed point is not a multiple of 3

## Jatin Arora (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/54597#comment_112932

I would like to clarify that starting with n*3 Matrix I remove p*3 points and then in the final array should be like the first point followed with n-p points. The numer of coulmns remain 3 whatever the case maybe

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/54597#comment_113050

What exactly are "points" here? Are you talking about n points in the 3D space?

Posting an explicit example as Matlab code is more accurate than a text description.

## Jatin Arora (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/54597#comment_114288

I would like to thank everyone who took time to read through my question and answer it. I woul like to say sorry as I could not reply due to some problem. After researching on the internet I found what exactly I want to implement.

I want to implement a Moving window filter in 3D space for cloud data of points.