minimum value array issue
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
aya
el 5 de Sept. de 2014
Comentada: aya
el 5 de Sept. de 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 comentarios
Respuesta aceptada
Guillaume
el 5 de Sept. de 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
Más respuestas (2)
per isakson
el 5 de Sept. de 2014
Editada: per isakson
el 5 de Sept. de 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
Rushikesh Tade
el 5 de Sept. de 2014
Editada: Rushikesh Tade
el 5 de Sept. de 2014
If removing of values is allowed :
[TransmiterNode,ind]=min(dn(:));
dn(ind)=[];
0 comentarios
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!