Minimum for different sized cell arrays
4 views (last 30 days)
Show older comments
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.
Accepted Answer
Walter Roberson
on 23 Nov 2017
To get the overall minima over a cell array without caring what the position is,
min( [YourArrayName{:}] )
3 Comments
Walter Roberson
on 23 Nov 2017
min( cell2mat( cellfun(@(Y, IDX) Y(IDX), y, index, 'uniform', 0) ) )
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!