フィルターのクリア

word manupulation

1 回表示 (過去 30 日間)
Amir Hamzah UTeM
Amir Hamzah UTeM 2012 年 6 月 6 日
i have 1 file in excel POS.xlsx contain word like this
A B
hello hi
enter exit
me you
love hurt
what how
when enter this word in edit text,my code working only for single wording let say i enter 'hello', it would show 'hi' when i enter 'hello me what' it wont show 'hi you how' what should i do to get that answer? below is my current code.
txt1=get(handles.ayat,'string');
[num,txt]=xlsread('POS.xlsx');
for i=1:length(txt)
txt2=txt{i,1};
compare1=strcmp(txt1,txt2)
if compare1 == 1
textOut=txt(i,2);
set(handles.tag,'String',textOut);
return;
else
promptMessage = sprintf('Maaf. Perkataan yang anda cari tidak terdapat dalam database');
selectedButton = questdlg(promptMessage, 'Mesej','Cuba Perkataan Lain','Keluar', 'Cuba Perkataan Lain');
if strcmp(selectedButton, 'Cuba Perkataan Lain')
set(handles.ayat,'String','');
return;
end
clear all;
clc;
close all;
return;
end
end
for i=1:length(txt)
txt2=txt{i,1};
txt3=txt{i,2};
t = strcat(txt1,txt3);
if t == 1
textOut=txt(i,2);
set(handles.tag,'String',textOut);
end
end

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 6 月 6 日
d ={'A' 'B'
'hello' 'hi'
'enter' 'exit'
'me' 'you'
'love' 'hurt'
'what' 'how'};
str1 = 'hello me what';
out = regexprep(str1,d(:,1),d(:,2));
  2 件のコメント
Amir Hamzah UTeM
Amir Hamzah UTeM 2012 年 6 月 6 日
thanks andrei :)
Amir Hamzah UTeM
Amir Hamzah UTeM 2012 年 6 月 6 日
how to check if the word entered is correct or not?
for example when i key in "hello what love" it will return 1
if i key in 'love is hurt' it will return 0

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by