minimum value array issue

3 Ansichten (letzte 30 Tage)
aya
aya am 5 Sep. 2014
Kommentiert: aya am 5 Sep. 2014
I am using the following code line to get the minimum value of the matrix dn and the corresponding index of the minimum value
[TransmiterNode,ind]=min(dn(:));
what I want to do is on the next run of this code line I do not want the old minimum value to be considered
  2 Kommentare
per isakson
per isakson am 5 Sep. 2014
Please elaborate a bit. Possibly provide a small example.
aya
aya am 5 Sep. 2014
let's say dn=[2 5 8 7 0 1] for the first iteration the result of [TransmiterNode,ind]=min(dn(:)); would be TransmiterNode=0 -----> the value ind=5 ---------> the index
for the next iteration I want the next minimum value without considering the previous one

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Guillaume
Guillaume am 5 Sep. 2014
If you know that all the values in dn are different:
%init
ind = [];
%for ...
dntemp = dn;
dntemp(ind) = [];
[TransmiterNode,ind]=min(dntemp(:));
%...
%end
If not:
%init
%TransmiterNode = NaN; %or any other unused value in dn
%for ...
dntemp = dn;
dntemp(find(TransmiterNode)) = [];
[TransmiterNode,ind]=min(dntemp(:));
%...
%end
  1 Kommentar
aya
aya am 5 Sep. 2014
thank you it's worked just I want it to

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

per isakson
per isakson am 5 Sep. 2014
Bearbeitet: per isakson am 5 Sep. 2014
Another approach, try
dn = [2 5 8 7 0 1];
[ dn_sorted, ix ] = sort( dn, 'ascend' );
ix contains the "positions" of the values in the original vector, dn
  1 Kommentar
aya
aya am 5 Sep. 2014
its a good idea but it does not effective for may program

Melden Sie sich an, um zu kommentieren.


Rushikesh Tade
Rushikesh Tade am 5 Sep. 2014
Bearbeitet: Rushikesh Tade am 5 Sep. 2014
If removing of values is allowed :
[TransmiterNode,ind]=min(dn(:));
dn(ind)=[];

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by