tags:

views:

27

answers:

2

Hi,

I have a v = 2x30 matrix and I need to take make another matrix to take all points of v whose y coordinates are positive

A: 

I suggest that you read the documentation on matrix indexing, and specifically the part about logical indexing. I believe the solution you're looking for is something like this:

vSub = v(:,v(2,:) > 0);  %# Extract columns where the second row is > 0
gnovice
This is a solution for a 30x2 matrix, and for non-negative `y`, not strictly positive.
aschepler
@aschepler: Right you are. Corrected now. I guess I'm too used to storing coordinate values in columns instead of rows.
gnovice
A: 
vPos = v(:, v(2,:) > 0);

creates the 2-by-n submatrix you described.

aschepler

related questions