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 Exchange에서 Operators 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