Borrar filtros
Borrar filtros

Searching the minimum element of an array

1 visualización (últimos 30 días)
Micaela
Micaela el 18 de Sept. de 2012
Hi..I have a question: if I have the result of a wavread, an array of samples, and I want to search the minimum element only between the last hundred elements and its index, how I can do this? I have some problems with the indices.
  1 comentario
Micaela
Micaela el 18 de Sept. de 2012
It's important for me to find also the index of the minimum.

Iniciar sesión para comentar.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 18 de Sept. de 2012
Editada: Azzi Abdelmalek el 18 de Sept. de 2012
v=rand(150,1)
[a0,idx0]=min(v(end-100:end))
% a0 your min
% idx0 corresponding index

Más respuestas (2)

Thomas
Thomas el 18 de Sept. de 2012
Editada: Thomas el 18 de Sept. de 2012
Something like this
a=rand(10,1) % your array
a =
0.81
0.91
0.13
0.91
0.63
0.10
0.28
0.55
0.96
0.96
indx = 7; % index at 7th element
min_a=min(a(indx:end)); minimum of between index and end
ans =
0.28
  1 comentario
Micaela
Micaela el 18 de Sept. de 2012
Ok...and if I want the index of the minimum, how I can find it?

Iniciar sesión para comentar.


HSO
HSO el 18 de Sept. de 2012
array=rand(20,1)
[L C] =size(a)
lower=min(a((L-10):end))
  2 comentarios
Micaela
Micaela el 18 de Sept. de 2012
Ok...and if I want the index of the minimum, how I can find it?
Javier
Javier el 18 de Sept. de 2012
Editada: Javier el 18 de Sept. de 2012
Hello Micaela
Step 1 Data
Data=randn(100,1);
Step 2 Find the min in Data
Index = 10; %Search in the last 10 data
x=min(Data((length(Data)-Index):end,:));
Step 3
Description row, column, index of min data
[r,c,v]= find(Data==x);
In this case, r=row vector; c=column vector; v=index value
Hope it helps.
Javier

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