"Sam " <sameiwater@gmail.com> wrote in message <jlcf1k$l3a$1@newscl01ah.mathworks.com>...
> 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:n3
> 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
        
A partial answer is that somewhere you will need the expression:
Data(ix)prod(Data(DataIndex(ix,:)==0))
This will give you the right sides of your indicated outputs for a general index 'ix' into 'Data'. I have no idea how you want your two outputs indexed however, so you will have to figure out how to use this to generate them in forloops.
Roger Stafford
