Ho to do

1 visualización (últimos 30 días)
Sukumar Palo
Sukumar Palo el 24 de Feb. de 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 comentarios
Robert Cumming
Robert Cumming el 24 de Feb. de 2011
what have you tried?
Jan
Jan el 24 de Feb. de 2011
You have posted the same question in CSSM. Rossposting confuses the people, who want to help you.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 24 de Feb. de 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 comentarios
Robert Cumming
Robert Cumming el 24 de Feb. de 2011
you still need to find where the max is. Jan has given you the answer - have you tried it?
Jan
Jan el 24 de Feb. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by