Distance Between Characters in String

Thank you for your help in advance. Suppose I have two strings namely, Source and Target,
Source: abcde
Target: hello
Is there a function for me to calculate the distance between the characters (using alphabetical series) in Source and Target?
Example answer: [7][3][9][8][10]
Explanation: [8-1][5-2][12-3][12-4][15-5]

 採用された回答

Stephen23
Stephen23 2016 年 8 月 30 日
編集済み: Stephen23 2016 年 8 月 30 日

0 投票

>> 'hello' - 'abcde'
ans =
7 3 9 8 10
Explanation: in MATLAB character arrays are arrays just like numeric arrays, so many mathematical operations can be performed on them. Read about character arrays:
If you want the edit distance, then use this algorithm:

1 件のコメント

RDG
RDG 2016 年 8 月 30 日
Thank you for such a simple and elegant solution!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

質問済み:

RDG
2016 年 8 月 30 日

編集済み:

2016 年 8 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by