Effacer les filtres
Effacer les filtres

finding the maximum of values after and before a specific value

6 vues (au cours des 30 derniers jours)
SSG_newbiecoder
SSG_newbiecoder le 19 Déc 2017
Commenté : SSG_newbiecoder le 22 Déc 2017
hello, I have a doubt.Is it possible to find out the maximum values before and after the ith element in an array?
  2 commentaires
Adam
Adam le 19 Déc 2017
Modifié(e) : Adam le 19 Déc 2017
yes
max( array( ( i + 1 ):end ) )
max( 1:( i - 1 ) )
SSG_newbiecoder
SSG_newbiecoder le 22 Déc 2017
Thanks Adam

Connectez-vous pour commenter.

Réponse acceptée

Birdman
Birdman le 19 Déc 2017
One approach:
a=randi([1 10],1,10);
ind=4;%4th element in a vector is chosen
a1=a(1:ind-1);
a2=a(ind+1,end);
max(a1)
max(a2)
  1 commentaire
SSG_newbiecoder
SSG_newbiecoder le 22 Déc 2017
Thank you. If anybody is using this please note that
a2=a(ind+1:end);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by