Path: news.mathworks.com!not-for-mail
From: "Phil Goddard" <philgoddardNOSPAM@telus.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Concatenate structure fields with empties
Date: Sun, 4 Jan 2009 22:30:04 +0000 (UTC)
Organization: Goddard Consulting
Lines: 13
Message-ID: <gjrd9c$gm1$1@fred.mathworks.com>
References: <gjo71f$ct5$1@fred.mathworks.com> <see-C54CAA.13113803012009@news.frontiernet.net> <gjqtvv$ku0$1@fred.mathworks.com>
Reply-To: "Phil Goddard" <philgoddardNOSPAM@telus.net>
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 1231108204 17089 172.30.248.38 (4 Jan 2009 22:30:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 4 Jan 2009 22:30:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 26433
Xref: news.mathworks.com comp.soft-sys.matlab:509776



A somewhat cryptic, and probably inefficient one liner is
result = cellfun(@(in) (1/(1/in)),{s.myField},'ErrorHandler',@(S,D) nan)

However a loop is probably just as good
for idx = 1:length(s)
   if isempty(s(idx).myField)
      s(idx).myField = nan;
   end
end
result = [s.myField];

Phil.