How to compare two strings with different sizes?
13 views (last 30 days)
Show older comments
Hi everyone,
I would like to make a matrix by comparing 2 sequences with different dimensions, if it's same character (eg: A-A), it will be traced to 1, if not it will be traced to 0.
a = 'AAGCTACGC'
b = 'ACGCAA'
However, I have trouble to make this matrix. Honestly, I am a beginner, hope you guys will help me.
Thanks a lot.
1 Comment
Accepted Answer
More Answers (1)
Jan
on 1 Mar 2021
A bold guess:
a = 'AAGCTACGC'
b = 'ACGCAA'
Nmin = min(numel(a), numel(b));
Nmax = max(numel(a), numel(b));
match = false(1, Nmax);
match(1:Nmin) = (a(1:Nmin) == b(1:Nmin));
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!