⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 naive_string_matching.m

📁 数据挖掘经典算法matlab实现
💻 M
字号:
function sh = Naive_String_Matching(text, x)

% Naive string matching: Find the location of the string x in text 'text'
%
% Inputs:
%	text				- Text vector
%	x					- Search string
%
% Output:
%	sh					- Locations of the string

n	= length(text);
m	= length(x);
s	= 0;
sh	= [];

while (s <= n - m),
   if strcmp(x, text(s+1:s+m)),
      disp(['The pattern occurs at shift ' num2str(s)])
		sh(end+1) = s;
   end
   s = s + 1;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -