Minimum for different sized cell arrays
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Joseph Lee
el 23 de Nov. de 2017
Editada: Joseph Lee
el 23 de Nov. de 2017
How do i find minimum value from indexing, it is simple for a matrix but how to do the same for different cells?
x & y are same sized
For matrix
x=10*rand(10,1300);
y=100*rand(10,1300);
idx=find(abs(x-1<0.005));
miny=min(y(idx))
For different sized cell arrays,
x&y= 10x1300 cell array containing the same different sized cells. Both are
Columns 1297 through 1300
[1×23 double] [1×29 double] [1×23 double] [1×25 double]
[1×25 double] [1×25 double] [1×25 double] [1×27 double]
[1×25 double] [1×27 double] [1×27 double] [1×25 double]
[1×29 double] [1×29 double] [1×25 double] [1×23 double]
[1×25 double] [1×23 double] [1×27 double] [1×27 double]
[1×27 double] [1×23 double] [1×21 double] [1×23 double]
[1×29 double] [1×27 double] [1×27 double] [1×27 double]
[1×21 double] [1×21 double] [1×29 double] [1×27 double]
[1×25 double] [1×25 double] [1×21 double] [1×27 double]
[1×25 double] [1×25 double] [1×25 double] [1×23 double]
index=cellfun( @(X) find(abs(X-1)<0.005), x, 'uniform', 0);
index results Columns 1297 through 1300, Index returns some zero cells.
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[ 25] [1×2 double] [1×2 double] [1×2 double]
[1×2 double] [1×2 double] [1×2 double] [1×2 double]
[1×2 double] [1×2 double] [1×2 double] [1×2 double]
[1×0 double] [1×0 double] [1×2 double] [1×2 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
How do i do the same to find the min as for a matrix, miny=min(y(idx)), a single value result.
Respuesta aceptada
Walter Roberson
el 23 de Nov. de 2017
To get the overall minima over a cell array without caring what the position is,
min( [YourArrayName{:}] )
3 comentarios
Walter Roberson
el 23 de Nov. de 2017
min( cell2mat( cellfun(@(Y, IDX) Y(IDX), y, index, 'uniform', 0) ) )
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion 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!