Date: Jan 1, 2014 4:50 AM
Author: Bruno Luong
Subject: Re: Extracting particular row of a matrix based on specific condition
dpb <email@example.com> wrote in message <firstname.lastname@example.org>...
> On 12/31/2013 2:16 AM, Bruno Luong wrote:
> > B(ismember(A,B(:,1)),2:end)
> That returns the rows in B for which the indices are found in A, not B,
> unfortunately, Bruno. It does get the first one correct as they're both
> in position 2, but then it returns fourth row, not first where the last
> element of A is found in first column of B...
You are write, it learns me not to do things too fast.
> >> [~,lb]=ismember(A,B(:,1));
> >> B(lb(lb>0),2:end)
> ans =
> 0.1300 0.0010 0.8900
> 0.1200 0.0050 0.1000
Should use the first argument of ismember() rather than recomputing it. Also OP requires the original order, so sort() will fix the order:
[t, iB] = ismember(A,B(:,1));