Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Select the data point in this range

Asked by Laura on 11 Jun 2013

I have a data point (x,y) that generates inside a cell -50 to 50 in the x- direction and the same with y.

Now I only want to pick the points that inside the cell from -25 to 25 both x and y.

Example: I have a matrix A contain x value in 1st column and y value in 2nd column

 A=[14 -12; 31 3; -14 43; 31 3]

The pair (14,-12) is the only pair inside -25 to 25 for both x and y. Note if only x is inside the range and y is not, then dont store it.

How do I store all the pair that in the range for the large matrix of A, say A=1000 x 2.

Thanks

0 Comments

Laura

Products

No products are associated with this question.

1 Answer

Answer by the cyclist on 11 Jun 2013
Edited by the cyclist on 11 Jun 2013
Accepted answer
xInRange = (x>=-25) & (x<=25);
yInRange = (y>=-25) & (y<=25);
xyInRange = xInRange & yInRange;
A = A(xyInRange,:);

You could roll the conditions into one statement, but I left them like this so you could see more clearly what I am doing.

0 Comments

the cyclist

Contact us