Usage of validateattributes with 'nonzero'
显示 更早的评论
I am wondering whether this is a bug:
validateattributes([0 0 1],{'numeric'},{'nonzero'})
Should result in an error, but the test passes as long as at least one element of the vector is nonzero. The function documentation says otherwise.
回答(1 个)
Adam
2017-3-22
Which version of Matlab are you using? In R2017b:
>> validateattributes( [0 0 1], { 'numeric' }, { 'nonzero' } )
Expected input to be nonzero.
so it looks to be working fine. Maybe it is a bug in an older version though. Strangely, in all my thousands of usages of validateattributes over the years I have never actually used 'nonzero' so hadn't even realised it existed as an attribute!
4 个评论
Dirk Twisk
2017-3-22
Adam
2017-3-22
Hmm, I don't have R2015b or earlier installed any more, but it works in R2016a. Maybe it was fixed for that version.
Dirk Twisk
2017-3-22
编辑:Dirk Twisk
2017-3-22
Adam
2017-3-22
That should certainly work fine
类别
在 帮助中心 和 File Exchange 中查找有关 Programming Utilities 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!