Longest Common Subsequence
Updated 27 Jul 2011
%%%X, Y - both are strings e.g. 'test' or 'stingtocompare'
%%%D is the substring over the length of the shortest string
%%%dist is the length of the substring
%%%aLongestString is a sting of length dist (only one of potentially many)
David Cumin (2023). Longest Common Subsequence (https://www.mathworks.com/matlabcentral/fileexchange/24559-longest-common-subsequence), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Changed the title to better represent the function. http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
Included support for 0 similarity
Now will also work for integer inputs (not only strings).
Sorry - a simple operator change fixed that. Should work now. The answer to your 'test' 'stingtocompare' is [0.5 2 'st'].