Matlab 有用的内置函数(2)

1. cellfun – Apply function to each cell in cell array 


A = cellfun(fun, C)
A = cellfun(fun, C, D, ...)
[A, B, ...] = cellfun(fun, C, ...)
[A, ...] = cellfun(fun, C, ..., 'param1', value1, ...)
A = cellfun('fname', C)
A = cellfun('size', C, k)
A = cellfun('isclass', C, 'classname')

A = cellfun(fun, C) applies the function specified by fun to the contents of each cell of cell array C, and returns the results in array A. The value A returned by cellfun is the same size as C, and the (I,J,…)th element of A is equal to fun(C{I,J,…}). The first input argument fun is a function handle to a function that takes one input argument and returns a scalar value. fun must return values of the same class each time it is called. The order in which cellfun computes elements of A is not specified and should not be relied upon.
Compute the mean of several data sets:

C = {1:10, [2; 4; 6], []};
Cmeans = cellfun(@mean, C)
Cmeans =
5.5000 4.0000 NaN

Find the positive values in several data sets:

Cpositives = cellfun(@(x) x(x>0), C, 'UniformOutput',false)
bg = cellfun2(@(x)sprintf(VOCopts.imgpath,x),neg_set);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Just another site

Jing's Blog

Just another site

Start from here......







Just another site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision


Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness



Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: