【发布时间】:2015-10-22 17:57:01
【问题描述】:
我见过一些代码使用:
index = findstr('something', 'longer string');
if ~isempty(index)
% do something
end
我查了the documentation for MatLab symbols here,它没有提到使用~ 将原始整数值转换为布尔值。即,如果索引为 10 或[],则isempty 将返回 0 或 1,使用 ~ 运算符将其转换为 1 或 0。但是,文档中没有提到这个用例。这是执行否定的合法方式吗?还有其他方法可以实现这种否定吗?
【问题讨论】:
-
Is A==0 really better than ~A?可能是相关的。
标签: matlab