[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using match to filter cell values
From: |
James Sherman Jr. |
Subject: |
Re: using match to filter cell values |
Date: |
Fri, 15 Oct 2010 16:22:34 -0400 |
On Fri, Oct 15, 2010 at 3:46 PM, Dr. Johannes Zellner
<address@hidden> wrote:
I'm not familiar with match, or how it works, but I think I can offer an alternative. I use the function "cellfun" a lot for what I think you're trying to do. For example, if you say wanted to find all the even entries in a cell array,
a = {0, 3, 4, 9, 10};
indices = cellfun(@x (mod(x,2))==0, a);
even_entries = a(indices);
cellfun maps each element in the cell array to what the output to the function is, and since it is logical output, we can use that to index into the cell array to get the even entries.
Hope this helps.