How do I check if all numbers in a vector are the same?
5 ビュー (過去 30 日間)
古いコメントを表示
I have a row vector A. I'd like to verify whether all numbers in this vector are the same. How can I do this?
Thanks!
0 件のコメント
採用された回答
Stephen23
2021 年 4 月 1 日
編集済み: Stephen23
2021 年 4 月 1 日
all(diff(A)==0)
min(A)==max(A) % does not work for NaN
range(A)==0 % RANGE requires the statistics toolbox
numel(unique(A))==1
1 件のコメント
Robert Brown
2021 年 4 月 1 日
Stephen actually gave not only 1 but what appears to be 3 solutions to the problem ! very good ! (overachiever !)
I don't seem to have range(A). Is that in a newer version of MATLAB? or is it in a toolbox?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!