Select all eelements equal to a number

3 ビュー (過去 30 日間)
Daniel Boateng
Daniel Boateng 2019 年 5 月 14 日
コメント済み: Daniel Boateng 2019 年 5 月 14 日
I have an array of elements x= [1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 4 4 7 7 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7];
I want to write a script that starts checking the array from the last element and when this is equal to 4 , it breaks and returns the rest of the array say b= [1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 4 4 7 7 4 4 4];
Please any help.
Thank you.

採用された回答

Adam
Adam 2019 年 5 月 14 日
b = x( 1:find( x == 4, 1, 'last' );
  1 件のコメント
Daniel Boateng
Daniel Boateng 2019 年 5 月 14 日
thank you very much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by