Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Get the first element out of each cell of a cell array
Date: Wed, 12 Mar 2008 05:34:01 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 24
Message-ID: <fr7q09$1vn$1@fred.mathworks.com>
References: <fr6rl1$ifj$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1205300041 2039 172.30.248.38 (12 Mar 2008 05:34:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 12 Mar 2008 05:34:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:456702



"David Doria":
<SNIP first in line only...

> I have a cell 4x20 cell array called L
> each element of L is a 1x20 vector
> How do I make a vector of all the first elements of L
(1,:)?
> I tried L(1,:)(1) to no avail...

one of the many solutions

% the data
     c=cell(2,3); % <- your 4x20 cell array
     [c{:}]=deal(1:3); % <- each element being a vec
% the engine
     ca=cat(1,c{:});
     r=ca(:,1);
% the result (as expected)
     disp(c);
     disp(r.');
% 1 1 1 1 1 1

us