Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply regexp to the cell array in Matlab?

I'm having the cell array res with cells 3x2, each of them containing a string. I want to apply regexp to each cell and it should look like that:

fin = cellfun(@regexp(res, '\.', 'split'),res,'UniformOutput',false)

however it doesn't do the job. Anyone knows how it can be combined properly?

like image 593
beginh Avatar asked Aug 22 '12 13:08

beginh


People also ask

What does Regexp do in Matlab?

Perform Case-Insensitive Matches By default, regexp performs case-sensitive matching. The regular expression specifies that the character vector: Begins with any number of alphanumeric or underscore characters, \w* . Ends with the literal text case .

Which brackets are used to put data into a cell array in Matlab?

To refer to elements of a cell array, use array indexing. You can index into a cell array using smooth parentheses, () , and into the contents of cells using curly braces, {} .


1 Answers

You were on the right track, but the syntax of your anonymous function is wrong. Try this:

fin = cellfun(@(x)regexp(x, '\.', 'split'), res, 'UniformOutput', false)
like image 172
Eitan T Avatar answered Sep 29 '22 10:09

Eitan T