Path: news.mathworks.com!newsfeed-00.mathworks.com!oleane.net!oleane!news.ecp.fr!club-internet.fr!feedme-small.clubint.net!proxad.net!feeder1-1.proxad.net!cleanfeed4-a.proxad.net!nnrp16-2.free.fr!not-for-mail
Date: Sun, 09 Sep 2007 23:33:54 +0200
From: David Bateman <dbateman@free.fr>
User-Agent: Thunderbird 1.5.0.7 (X11/20060921)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: Vectorizing Assignment to array of structures?
References: <fc1m8v$b6r$1@fred.mathworks.com>
In-Reply-To: <fc1m8v$b6r$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Lines: 33
Message-ID: <46e466c2$0$7346$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 09 Sep 2007 23:33:54 MEST
NNTP-Posting-Host: 81.57.137.98
X-Trace: 1189373634 news-3.free.fr 7346 81.57.137.98:50979
X-Complaints-To: abuse@proxad.net
Xref: news.mathworks.com comp.soft-sys.matlab:427576



First Last wrote:
> Hello, 
> 
> I have a variable 'data' that is a 1x2 structure array with
> the fields in which:
> 
> data.times are 5x1 vectors 
> data.mean are numbers
> 
> I can clearly access the data.mean and data.times values and
> manipulate them, but is there a way I can assign each one of
> the data.mean values in a vector, quickly, without a loop? 
> 
> For instance, let's say I want 
> 
> data(1).mean = 5;
> data(2).mean = 7;
> 
> Is there a way to assign the vector [5 7] to data.mean?
> Obviously this example there is only a marginal
> computational penalty for doing this somewhat manually, but
> for larger arrays of structures, this could be a nightmare.
> I'm trying to vectorize this thing as much as possible.
> 
> Thanks in advance.
> 

Maybe I'm missing something, but what is wrong with

data = struct('mean', {5,7})


D.