Minimum for different sized cell arrays
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joseph Lee
am 23 Nov. 2017
Bearbeitet: Joseph Lee
am 23 Nov. 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.
Akzeptierte Antwort
Walter Roberson
am 23 Nov. 2017
To get the overall minima over a cell array without caring what the position is,
min( [YourArrayName{:}] )
3 Kommentare
Walter Roberson
am 23 Nov. 2017
min( cell2mat( cellfun(@(Y, IDX) Y(IDX), y, index, 'uniform', 0) ) )
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion 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!