Reputation: 264
selection = {[1],[1,2],[1,2,3]}';
AIC = [0.00 0.01 0.00]';
for ii = 1:size(selection,1);
sizer(ii) = size(selection{ii,1},2);
end
sizer = sizer';
pick = selection{AIC == min(AIC)}
See the above example,
I am trying to select the minimum AIC which as the highest sizer value,
I would like 'pick' to select [1,2,3] instead of [1].
Thanks
Upvotes: 0
Views: 70
Reputation: 1861
You can use cellfun
with @size
to get all the sizes, and use max
to get max size:
sizes = cellfun(@size, selection, 'UniformOutput', false);
pick = max([sizes{AIC == min(AIC)}])
Upvotes: 2