How can i find positions of sorted/unique values.

1 回表示 (過去 30 日間)
Triveni
Triveni 2016 年 1 月 26 日
コメント済み: Triveni 2016 年 1 月 26 日
p = [90 90 -45 0 0 45 45 0 -45];
q = p;
q(1+find(q(1:end-1)==q(2:end))) = [];
q = [90 -45 0 45 0 -45];
idx = [true diff(p)~=0];
q = p(idx);
i want to find positions of q according to p from right to left. Means [2 3 5 7 8 9]

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 1 月 26 日
idx = fliplr([true, diff(fliplr(p))~=0]);
out = find(idx);
  1 件のコメント
Triveni
Triveni 2016 年 1 月 26 日
Thanks Andrei

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by