I need to remove some data points from a matrix and then use these points in a function? how would i do this? The matrix is 3x1470, each column refers to XYZ and i am looking to remove all points within a certain radius from the centre.

조회 수: 8 (최근 30일)
I am doing analysis is vibrometer readings and there is a circular discontinuity in the centre of the plate. I am looking to remove all data points within a certain radius of the centre of the plate and use the remaining data in energy calculations for which I have working functions.

답변 (1개)

Josh
Josh 2017년 8월 17일
Here's how to do it using bsxfun:
% I'll define 1000 random points in a 100 x 100 x 100 cube (in your case,
% you'll just use your xyz data):
points = 100 * rand(1000, 3);
% I'll define the position of the center of the plate:
center = [50, 50, 50];
% I'll define the radius I want to clear
radius = 15;
% This next part can be put in one line, but I'll break it up so I can
% explain it:
% Get the vector distance between all the points and the center of the
% plate:
distance = bsxfun(@minus, points, center);
% If you'r not famililar with bsxfun, what I just wrote works the same as:
distance = points - repmat(center, size(points, 1), 1);
% but has less overhead
% Now calculate the (squared) absolute distance
distance = sum(distance .^ 2, 2);
% Now create a logical array where each value corresponds to one of your
% input points. 'True' means keep the point, 'False' means get rid of it,
% it's too close to the center:
keep = distance > radius .^ 2;
% Now discard the points that are too close to the center:
points = points(keep, :);

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by