How to calculate index of minimum value in cell array
Mostrar comentarios más antiguos
Hello, I have a cell array by name m1 of size 374 * 3 (where m1(1,1}=1 * 8,m1{1,2}=1*8 and m1{1,3}=1*1..totally there are 17 cells)..Now i want minimum value index from all this cells... for example if m1{1,1}=[0.34463 0.3276 0.3615 0.3446 0.3559 0.3389 0.3389 0.3446], m1{1,2}=[0.36723 0.3333 0.3615 0.3615 0.3446 0.3559 0.3163 0.3333] and m1{1,3}=[0.3390] ....now minimum value is 0.3163 and it's index value is m1{1,2}(1,7)... so,likewise i want the minimum index value from all 374 cells...
Respuesta aceptada
Más respuestas (2)
KSSV
el 9 de Mayo de 2017
m1{1,1}=[0.34463 0.3276 0.3615 0.3446 0.3559 0.3389 0.3389 0.3446] ;
m1{1,2}=[0.36723 0.3333 0.3615 0.3615 0.3446 0.3559 0.3163 0.3333] ;
m1{1,3}=[0.3390] ;
iwant = cell(size(m1)) ;
for i = 1:length(m1) ;
[idx,val] = min(m1{i}) ;
iwant{i} = [idx,val] ;
end
3 comentarios
Jyothi Alugolu
el 9 de Mayo de 2017
Jyothi Alugolu
el 9 de Mayo de 2017
KSSV
el 9 de Mayo de 2017
What do you think is idx in the above code?
Jan
el 9 de Mayo de 2017
[MinValue, MaxValue, MinIndex, MaxIndex, MinArg, MaxArg] = MinMaxElem(m1{:});
In older Matlab version this was faster than calling min and max separately, but modern Matlab versions are more efficient.
Categorías
Más información sobre Correlation and Convolution en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
