extracting matrix row whose element which satisfy equation of a cirlce

I have a nx2 matrix. Each row is actually a coordinate point. I have a coordinate of center of a circle and its radius. I want to build a matrix that only contains those row of nx2 matrix whose 1st and 2nd element lie inside or on the given circle. Any hints?

 Respuesta aceptada

What's the difficulty?
%points: nx2 matrix of points
%centre: 1x2 vector of circle centre
%radius: radius of circle
isincircle = sum((points - centre) .^2, 2) <= radius .^ 2; %only works in R2016b
incirclepoints = points(isincircle, :)
If < R2016b,
isincircle = sum(bsxfun(@minus, points, centre) .^2, 2) <= radius .^ 2;

Más respuestas (0)

Categorías

Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 23 de Nov. de 2016

Respondida:

el 23 de Nov. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by