Checking for multiple values that are the same in a vector
古いコメントを表示
I have a vector of data values and would like to flag up if there are several identical values in a row.
If the data were A=[1,2,3,4,4,4,4,5,6,7,8] I would want it to flag up that there were 4 fours so that I could correct the values.
Is there a way of doing this other than a for loop with checking if A(2)==A(1)
Ideally it would only flag up an error if more than 10 were the same in a row (my real data is a lot larger than A).
Thanks
2 件のコメント
madhan ravi
2019 年 7 月 10 日
Explicitly show how your result should look like.
elspeth storey
2019 年 7 月 10 日
採用された回答
その他の回答 (1 件)
KSSV
2019 年 7 月 10 日
B=[1,2,3,4,4,4,4,5,6,7,8] ;
[a,b]=hist(B,unique(B)) ;
[b' a']
2 件のコメント
elspeth storey
2019 年 7 月 10 日
KSSV
2019 年 7 月 10 日
REad about unique. This gives indices also...
カテゴリ
ヘルプ センター および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!