This answer is the same as @Dan, but if necessary uses a simple loop to improve performance.
% If you know that the numel of elements returned by {2,2} will always be one: nElem = numel(B); ret(1,nElem)=0; for k=1:nElem ret(k) = A{1,B(k)}{2,2} end
The following answer is incorrect, it will return the index {2,2} from the first element from B
subsref([A{1,B}],struct('type','{}','subs',{{2,2}}))
Which is more like what you are doing (and not using cellfun and arrayfun , it would be better if you perform this operation in a loop because they are slow )
See the subsref documentation here .
Longer way:
temp = [A{1,B}] temp{2,2}
source share