이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Possibility to vectorize this code?

조회 수: 1 (최근 30일)
Léon . 2012년 10월 15일
마감: MATLAB Answer Bot . 2021년 8월 20일
I am trying to find a way to vectorize this code, but because of the +1 indices I can't get it done. Is there any possibility? Thank you very much for your help!
d = toeplitz(find(s1),find(s2))-1;
for j = 1:numel(s2)-1
for i = 1:numel(s1)-1
d(i+1,j+1) = min(min(d(i,j+1),d(i+1,j)) + 1,d(i,j) + ne(s1(i), s2(j)));
  댓글 수: 1
Matt Fig
Matt Fig 2012년 10월 15일
It would help if we had some code that we could actually run. Like give sample data for s1, s2, ne that is representative of the real data in size and class...

답변 (1개)

Léon 2012년 10월 16일
Hello Mat, no problem. Use just:
s1 = 'house';
s2 = 'mouse';
ne is a function so that's all you need, I guess

Community Treasure Hunt

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

Start Hunting!

Translated by