find if a column vector contains at least element 1

2 次查看(过去 30 天)
I have to check if column vector has at least element 1. Does Matlab have such similar function or I have to build it myself?

采纳的回答

Sean de Wolski
Sean de Wolski 2012-9-20
tf = any(A(:)==1)

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2012-9-20
编辑:Azzi Abdelmalek 2012-9-20
length(a)
Or
numel(a)
  2 个评论
Salvatore Mazzarino
No I don't mean check if the matrix has at lest one element. I would know if the matrix contains at least 1. For example:
A=[1 0 0]
this contains 1.
B=[0 0 0]
this contains all zeros.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by