Select all eelements equal to a number

5 vues (au cours des 30 derniers jours)
Daniel Boateng
Daniel Boateng le 14 Mai 2019
Commenté : Daniel Boateng le 14 Mai 2019
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.

Réponse acceptée

Adam
Adam le 14 Mai 2019
b = x( 1:find( x == 4, 1, 'last' );
  1 commentaire
Daniel Boateng
Daniel Boateng le 14 Mai 2019
thank you very much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by