Stuart’s MATLAB Videos

Watch and Learn

Searching for permutations of a string in a list in MATLAB

In this video a colleague was looking in a large list to see if each element was a permutation of any element of a shorter list. I name these lists Haystack and Needle so it is easy to remember which I am looking for and which I am looking through. Because we are looking for any permutation of a three character string, it might seem like we would have to search three times for each element in the needle list. It turns out, if you sort the elements of each list, the permutations are no longer an issue. The function ismember is also useful in making this string searching in MATLAB go very quickly.
|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.