|
On 3/29/2012 9:02 AM, David Epstein wrote:
> I have an NxM cell array. Each cell contains a UxV logical array (same U
> and same V throughout). How can I "or" all the N*M logical arrays
> together, to get a UxV answer?
> Can I do it in one line? Perhaps I should use "max", but I don't see how.
Starting with the cell array,
c = cell(N,M);
% Fill cell array with UxV logical arrays.
You could put the cells together in a 3-D array and then use any:
result = any(cat(3,c{:}),3);
but that builds an intermediate matrix with NxMxUxV elements so if that
is large you might want to use a loop:
result = false(U,V);
for i = 1:N*M
result = result | c{i};
end
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
|