From: Jan Simon on 27 Mar 2010 20:26 Dear forkandwait w! > Is there a quick way to recode a cell array of strings, preferably using a 2xN cell array of pattern/ code pairs? > > For example: > a = {'aa', 'ab', 'cc', 'aa'} > recode (a, {'a.*', 'A'; 'c.*', 'C'}) > => {'A', 'A', 'C', 'A'} > > Maybe there is a nice way to do this with cellfun, but there might be an idiom or function special made that I don't know about. Please offer some more examples to show the general problem. For this example, this would work: a = {'aa', 'ab', 'cc', 'aa'} upper(cellfun(@(c) c(1), 'UniformOutput', false)) Kind regards, Jan
|
Pages: 1 Prev: recode strings en masse Next: What is the proper way to read/write sparse matrix? |