Path: news.mathworks.com!not-for-mail
From: "Sam " <sameiwater@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: loop
Date: Mon, 2 Apr 2012 15:02:13 +0000 (UTC)
Organization: University of British Columbia
Lines: 33
Message-ID: <jlcf1k$l3a$1@newscl01ah.mathworks.com>
Reply-To: "Sam " <sameiwater@gmail.com>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1333378933 21610 172.30.248.35 (2 Apr 2012 15:02:13 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 2 Apr 2012 15:02:13 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3336765
Xref: news.mathworks.com comp.soft-sys.matlab:762920

There is a vector Data, which is:

Data=rand(1,41)';

I need to define two different outputs for this Data

N=(1:1:6);
n = length(N);
DataIndex = zeros((n^3+5*n+6)/6,n); 
p = n:-1:1;
s = 0;
for k = n:-1:n-3
    c = nchoosek(p,k);
    for m = 1:size(c,1)
        s = s + 1;
        DataIndex(s,c(m,:)) = N(c(m,:));        
    end
end

DIndex=DataIndex(2:end,:);

% Index indicating which values we need in both Data and DIndex (where the values are zero) for example

Out1_1=Data(7)-Data(1)*Data(2); 
Out1_15=Data(21)-Data(5)*Data(6);
Out2_16=Data (22)-Data(1)*Data(2)*Data(3); 
Out2_35=Data (41)-Data(4)*Data(5)*Data(6); 

I need to write a loop that took the data and excute this function.

Thanks,

Sam