Path: news.mathworks.com!not-for-mail From: "Ulrik Nash" <uwn@sam.sdu.dk> Newsgroups: comp.soft-sys.matlab Subject: An even nastier vector operation! Date: Thu, 18 Mar 2010 16:55:21 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 23 Message-ID: <hntltp$r3r$1@fred.mathworks.com> Reply-To: "Ulrik Nash" <uwn@sam.sdu.dk> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1268931321 27771 172.30.248.35 (18 Mar 2010 16:55:21 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Thu, 18 Mar 2010 16:55:21 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 2106050 Xref: news.mathworks.com comp.soft-sys.matlab:617971 Hi Everyone, In extension to a problem posted yesterday (Subject: Complicated vector operation!), I am having trouble with a perhaps even nastier version! Suppose I have a horizontal vector, "A". For example: A = [2 3 5 5 1 4] Suppose also that I have a vertical vector of integers: number_in_sample = [1 3 5]' Now I wish to create a vertical vector, called "averages", which consists of averages of numbers drawn from A, where the number of elements drawn (without replacement), is defined by the vector number_in_sample. So, the number of elements in "averages", is equal to the number of elements in "number_in_sample". Can this be done without the need to loop? I appreciate the help. Regards, Ulrik.