フィルターのクリア

Removing non unique elements from an array after n entries

3 ビュー (過去 30 日間)
Sean
Sean 2014 年 6 月 30 日
コメント済み: Image Analyst 2014 年 6 月 30 日
If I have an array:
[1 2 3 4 5 6 8 1 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 .... 5]
^
How can I remove the remaining 5s after say, here?
  2 件のコメント
Sean
Sean 2014 年 6 月 30 日
I want to be able to delete after ten 5s (or after some number of 5s in the array) the remaining values in the array without prior knowledge of the location (^).
Cedric
Cedric 2014 年 6 月 30 日
Should the first 5 (between 4 and 6) be accounted in the count of 5s?

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

採用された回答

Image Analyst
Image Analyst 2014 年 6 月 30 日
out = yourVector(1:18);
  1 件のコメント
Image Analyst
Image Analyst 2014 年 6 月 30 日
Regarding your additional comment:
m = [1 2 3 4 5 6 8 1 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5]
maxNumber = 7; % How many 5's do you want to keep.
indexes = find(m == 5)
m_out = m(1 : indexes(maxNumber))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by