Effacer les filtres
Effacer les filtres

Ho to do

1 vue (au cours des 30 derniers jours)
Sukumar Palo
Sukumar Palo le 24 Fév 2011
hi
I have an array of 50 data points as 1X50. I want to find out 3 points prior to the maximum value in the array.
eg: the maximum value is on 27th position I want solution that will return the 24th position in the array
how to do it
thanx in advance
  2 commentaires
Robert Cumming
Robert Cumming le 24 Fév 2011
what have you tried?
Jan
Jan le 24 Fév 2011
You have posted the same question in CSSM. Rossposting confuses the people, who want to help you.

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 24 Fév 2011
Have you read the help text of MAX?
x = rand(1, 50);
[maxValue, maxIndex] = max(x);
maxIndexMinus3 = maxIndex - 3;
Most likely this might cause troubles if the first element is the maximum. So perhaps you want this:
maxIndexMinus3 = max(1, maxIndex - 3);
  3 commentaires
Robert Cumming
Robert Cumming le 24 Fév 2011
you still need to find where the max is. Jan has given you the answer - have you tried it?
Jan
Jan le 24 Fév 2011
What exactly are the inputs of your problem? Do you know the index of the maximum initially? Then use just the last line I've posted. If you don't now the index of the maximum, the function has to find it of course.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing 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