Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
检查向量是否仅包含零的“ MATLAB方式”是什么,以便将其评估为标量而不是向量。如果我运行此代码:
vector = zeros(1,10) %the "1" represents a function that returns a scalar if 1 && vector == 0 %this comparision won't work 'success' end 我得到错误: ??? ||的操作数和&&运算符必须可转换为逻辑标量值。回答: all使用: vector = zeros(1,10) if 1 && all(vector == 0) %this comparision will work 'success' end 更多&回答... |
![]() |
![]() |