|
"us " <us@neurol.unizh.ch> wrote in message <gq1b6t$bf3$1@fred.mathworks.com>...
> "Jonathan"
> > j = [time data]; %8760*4 matrix
> > m = maxtab(:,1); %Column of data
> > rows = find(ismember(time, m,'rows')); %find those rows where m value matches time value
> > j(rows,:)=[];
> > What I am trying to do is extract those lines that correspond to the m value from matrix j. The last line deletes the rows in J that correspond to m. However, what I need is the opposite, which is delete all other values and retain only those J rows that correspond to the m values...
>
> a nice example of the strength of
> - logical indexing, which is what you want
> and
> - linear indexing, which is what FIND unnecessarily does for you in this case
>
> one of the solutions
>
> d=[1,3,4,5,7,9];
> t=[1,7,2];
> ix=ismember(d,t)
> % ix = 1 0 0 0 1 0
> dok=d(ix)
> % dok = 1 7
> dnotok=d(~ix)
> % dnotok = 3 4 5 9
>
> us
Hmmm, while this approach seems better than using find, it still does not resolve my original problem.
If my original matrix 'd' in your example above is 8760*4, and 't' is 9*1, what I would like to be able to do is for the 9 't'-values, use these to identify the same row values in 'd' and place those specific 'd'-rows in a new matrix say 'rows', which would have a size of 9*4.
Thanks again for your help.
Jon
|