How to compare values in one vector?

1 回表示 (過去 30 日間)
huanghui shi
huanghui shi 2020 年 4 月 9 日
回答済み: KSSV 2020 年 4 月 9 日
for example B=[1,2,2,5,4,4]
so i only want output 1,5,i dont want 2,4 because they have same value in this vector.
how to do this within fop-loop?
  1 件のコメント
BN
BN 2020 年 4 月 9 日
You can use the unique function

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2020 年 4 月 9 日
a=[1,2,2,5,4,4];
xbins = unique(a);
[counts,centres] = hist(a,xbins);
iwant = a(counts==1)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by