Find elements meeting any of a number of criteria

后端 未结 4 1539
花落未央
花落未央 2020-12-19 05:27

I am trying to find the indices of elements in a vector that correspond to another vector, preferably without using loops. For example, my input might be:

DJ         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 05:55

    Perhaps you could try intersect? It is suppose to be a lot faster:

    [Intersect,indDJiSet,indJiSet] = intersect(DJiSet,JiSet)
    

    The ordering does not matter, as long as the element exist in both list, the ind elements gives the index.

提交回复
热议问题