필터 지우기
필터 지우기

Searching the minimum element of an array

조회 수: 1 (최근 30일)
Micaela
Micaela 2012년 9월 18일
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
Micaela
Micaela 2012년 9월 18일
It's important for me to find also the index of the minimum.

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 18일
편집: Azzi Abdelmalek 2012년 9월 18일
v=rand(150,1)
[a0,idx0]=min(v(end-100:end))
% a0 your min
% idx0 corresponding index

추가 답변 (2개)

Thomas
Thomas 2012년 9월 18일
편집: Thomas 2012년 9월 18일
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
Micaela
Micaela 2012년 9월 18일
Ok...and if I want the index of the minimum, how I can find it?

댓글을 달려면 로그인하십시오.


HSO
HSO 2012년 9월 18일
array=rand(20,1)
[L C] =size(a)
lower=min(a((L-10):end))
  댓글 수: 2
Micaela
Micaela 2012년 9월 18일
Ok...and if I want the index of the minimum, how I can find it?
Javier
Javier 2012년 9월 18일
편집: Javier 2012년 9월 18일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by