Path: news.mathworks.com!not-for-mail
From: "Sven" <sven.holcombe@gmail.deleteme.com>
Newsgroups: comp.soft-sys.matlab
Subject: Concatenate structure fields with empties
Date: Sat, 3 Jan 2009 17:25:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 14
Message-ID: <gjo71f$ct5$1@fred.mathworks.com>
Reply-To: "Sven" <sven.holcombe@gmail.deleteme.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1231003503 13221 172.30.248.35 (3 Jan 2009 17:25:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 3 Jan 2009 17:25:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1326470
Xref: news.mathworks.com comp.soft-sys.matlab:509667


Hi there, just a question about concatenating structure array fields where some of the arrays don't have that field initialised. For example:

s(1).myField = 100;
s(10).myField = 200;

[s.myField], or cat(1,s.myfield), both give a result of length 2 since all the other entries are empty.

I understand you can't have a 1 by 10 array with elements 2 to 9 being empty. How about instead returning those elements as nan?

Basically, what's the most efficient way for me to concatenate these structure fields, yet retain the indices where each element was found in the structure.

Cheers,
Sven.