|
From: | Junqian Gordon Xu |
Subject: | Re: using match to filter cell values |
Date: | Fri, 15 Oct 2010 18:05:53 -0500 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9) Gecko/20100918 Lightning/1.0b2 Icedove/3.1.4 |
On 10/15/2010 03:22 PM, James Sherman Jr. 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);
^^^ syntax error
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.
indices = cellfun(@(x) mod(x,2)==0, a); Gordon
[Prev in Thread] | Current Thread | [Next in Thread] |