MATLAB Answers

carlos Uribe

Calling multiple cell elements at once

Asked by carlos Uribe
on 17 Nov 2012


I have a cell something like

        [1x3 double]    [1x3 double]    [1x3 double]    [1x3 double]

Is it possible to call the first position of each vector at once? Something like



Matt J
on 17 Nov 2012

Since your A{i} are all the same size and numeric type, it is puzzling why you would maintain it in cell form, as opposed to a 4x3 matrix for example.

Hi Matt, thanks for your reply...Yes I guess I chose a bad example but I just chose a bad example for what I want to do...not necessarily all of them will be the same size still I would like to call the first position for different purposes.



No products are associated with this question.

2 Answers

Answer by Azzi Abdelmalek
on 17 Nov 2012
 Accepted answer



Answer by per isakson
on 17 Nov 2012

Not with plain indexing. This one-liner does it

    r = cellfun( @(v) v(1), A )

However, ...


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!