我正在使用strfind'或'比较,如下所示:
name='hello';
if strfind(name,'hello') | strfind(name,'hi')
disp('yes!')
end
>> yes!
Run Code Online (Sandbox Code Playgroud)
该if语句必须为评估true以来,yes!被显示出来.
相反,yes!如果交换语句,MATLAB不会返回:
if strfind(name,'hi') | strfind(name,'hello')
disp('yes!')
end
Run Code Online (Sandbox Code Playgroud)
为什么?