VBA在MATLAB中的“赞”功能

时间:2019-03-19 17:21:23

标签: vba matlab

我该如何转成

str1像“? ab ?”

进入MATLAB吗?

2 个答案:

答案 0 :(得分:1)

MATLAB函数contains是可以在VBA中使用的Like

请注意 contains 已引入MATLAB 2016b。

答案 1 :(得分:0)

您可能希望查看与regular expressions(“ regexp”)匹配的字符串。请注意,Matlab使用的regexp语法与VBA中使用的regexp语法不同。在您的示例中,“。”扮演'?'的角色通配符,以便您可以

str1 = 'aabb'; % Match
str2 = 'abab'; % No match

if isempty(regexp(str1, '.ab.'))
  disp('str1 is no match');
else
  disp('str1 is a match');
end

if isempty(regexp(str2, '.ab.'))
  disp('str2 is no match');
else
  disp('str2 is a match');
end

您应该得到的输出是

  

str1是一个匹配项

     

str2不匹配

相关问题