strcmpi not returning 1

조회 수: 3 (최근 30일)
Asahel Aguilar-Ortiz
Asahel Aguilar-Ortiz 2019년 12월 5일
댓글: Asahel Aguilar-Ortiz 2019년 12월 5일
% So I'm trying to find overlap between two strings. I am trying to use a logical index but compare never returns 1, any suggestions?
function [ combined, overlap ] = AssembleSeqs(left, right)
combined=[];
overlap=[];
shorter= min(length(left), length(right))
tester=[1:shorter];
for i=1:1:shorter
tester(i)=0;
leftend=left(end-i+1)
rightend=right(i)
compare=strcmpi('leftend','rightend')
if (compare==1)
tester(i)=1;
end

채택된 답변

galaxy
galaxy 2019년 12월 5일
You need compare string from 2 variables leftend and rightend, but you are comparing 2 string 'leftend' , 'rightend'.
Let remove apostrophe and sure about 2 variables leftend and rightend are string
  댓글 수: 1
Asahel Aguilar-Ortiz
Asahel Aguilar-Ortiz 2019년 12월 5일
This did fix the problem. Such a simple error, thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by