I need to return matches from a large cell array given one row to match. I wrote this code, but it seems like it shouldn't be this challenging - the code feels overwrought. What's the right way to do this?
function locations= MatchRowInHaystack(haystack,needle)
%Returns array locations: where needle matches haystack
%Where Needle is a cell array of identifiers
%And Haystack is a cell array of rows that may match needle.
%Split haystack into cell arrays by row:
rows=mat2cell(haystack,ones(size(haystack,1),1),size(haystack,2));
%Find row in haystack that matches needle row.
locations=find(cellfun(@isequal,rows,repmat({needle},[numel(rows) 1])));
end