2

Say I have a matrix A, and I want to construct a matrix B that contains all rows of B that start with a particular number. How? Thanks

0

1 Answer 1

9

Select all rows of B into A, where the first colum of B has value n:

A = B(B(:,1) == n,:); 

In contrast to that, the following selects all rows of B into A, starting from row index n:

A = B(n:end,:); 
Sign up to request clarification or add additional context in comments.

2 Comments

No, I meant rows that contain the particular number. For example, if A=[1 2; 3 4; 1 7] and we look for all rows starting with 1, I'd like to get [1 2; 1 7]
I merged the other answer into that one.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.