1

i have a matrix B of N*3 dim. I want to find the indices of B whose column 3 has value 1.

I used the command [~,id]=ismember(1,B(:,3)). id returns only value 1 even though there are many rows in the matrix which has the column 3 with value 1. Can any one point out what is wrong in the command?

1 Answer 1

3

Rather do:

id = find(B(:,3)==1)

but as an aside, to use ismember you should swap your input [~,id]=ismember(B(:,3),1).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.