strcmpi not returning 1

2 ビュー (過去 30 日間)
Asahel Aguilar-Ortiz
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 Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by