Prev: Image compression
Next: basic problem with simulink
From: Ozge Taskan on 9 Jul 2010 23:25 "Matt Fig" <spamanon(a)yahoo.com> wrote in message <hsrrsd$o20$1(a)fred.mathworks.com>... > I see. If Jos is correct, then you can also do this with a slight modification of the solution I gave earlier. > > > [m,n] = size(A); > Rr = npermutek(1:n,m); % The "Row-Rank" matrix. > G = A((Rr-1)*m+repmat(1:m,n^m,1)); > > IIRC, COMBN and NPERMUTEK do the same thing using different methods. Hi, I would like to ask something related to same thing. If we have 9 numbers and we would like to assign one of the numbers below how can we look at each possibilities for example 1st number can be 1 or 4 2nd number can be 1 or 4 3rd number can be 4 4th number can be 1 or 2 or 3 5th number can be 1 or 2 or 3 6th number can be 1 or 2 or 3 7th number can be 3 8th number can be 2 or 3 9th number can be 1 or 2 or 3 how can we construct 2*2*1*3*3*3*1*2*3(648) numbers? thank you very much in advance.
From: Ozge Taskan on 10 Jul 2010 00:51 "Ozge Taskan" <lordgy(a)yahoo.com> wrote in message <i18p6g$kri$1(a)fred.mathworks.com>... > "Matt Fig" <spamanon(a)yahoo.com> wrote in message <hsrrsd$o20$1(a)fred.mathworks.com>... > > I see. If Jos is correct, then you can also do this with a slight modification of the solution I gave earlier. > > > > > > [m,n] = size(A); > > Rr = npermutek(1:n,m); % The "Row-Rank" matrix. > > G = A((Rr-1)*m+repmat(1:m,n^m,1)); > > > > IIRC, COMBN and NPERMUTEK do the same thing using different methods. > > Hi, > I would like to ask something related to same thing. > If we have 9 numbers and we would like to assign one of the numbers below how can we look at each possibilities for example > 1st number can be 1 or 4 > 2nd number can be 1 or 4 > 3rd number can be 4 > 4th number can be 1 or 2 or 3 > 5th number can be 1 or 2 or 3 > 6th number can be 1 or 2 or 3 > 7th number can be 3 > 8th number can be 2 or 3 > 9th number can be 1 or 2 or 3 > how can we construct 2*2*1*3*3*3*1*2*3(648) combinations? > > thank you very much in advance.
From: Roger Stafford on 10 Jul 2010 02:22 "Ozge Taskan" <lordgy(a)yahoo.com> wrote in message <i18p6g$kri$1(a)fred.mathworks.com>... > Hi, > I would like to ask something related to same thing. > If we have 9 numbers and we would like to assign one of the numbers below how can we look at each possibilities for example > 1st number can be 1 or 4 > 2nd number can be 1 or 4 > 3rd number can be 4 > 4th number can be 1 or 2 or 3 > 5th number can be 1 or 2 or 3 > 6th number can be 1 or 2 or 3 > 7th number can be 3 > 8th number can be 2 or 3 > 9th number can be 1 or 2 or 3 > how can we construct 2*2*1*3*3*3*1*2*3(648) numbers? > > thank you very much in advance. - - - - - - - - - - You can accomplish that using numbers with mixed bases. That is, start with the number 0 and count by ones up to 648-1. For each one of these numbers, compute the nine digits that would represent that number with the nine different bases 2, 2, 1, 3, 3, 3, 1, 2, 3. If 1 is added to each of these digits, they can be used as indices into a cell array containing all the number sets possible for each digit: the first digit can be 1 or 4, the second one also 1 or 4, the third one only 4, the fourth 1, 2, or 3, etc. For example, the number N = 556 can be represented in the mixed bases above by: 1 1 0 1 0 2 0 1 1 since 556 = ((((((((1)*2+1)*1+0)*3+1)*3+0)*3+2)*1+0)*2+1)*3+1 Suppose v = [2 2 1 3 3 3 1 2 3] contains the nine bases, that is the nine lengths in the cell array. Suppose N = 556. You can obtain these nine digits with a for-loop: q = N; for k = 9:-1:1 r = mod(q,v(k)); q = (q-r)/v(k); % At this point use r+1 as an index into the k-th cell array % of possible numbers and place result in a matrix, X(N+1,k) end You would have an outer for-loop going through all the possible values of N from 0 to 647. I'll let you work out the rest of the details. The only difference between the above and converting a number to decimal or binary digits is that the bases are variable in this situation. Roger Stafford
From: Bruno Luong on 10 Jul 2010 05:03 "Ozge Taskan" <lordgy(a)yahoo.com> wrote in message <i18p6g$kri$1(a)fred.mathworks.com>... > "Matt Fig" <spamanon(a)yahoo.com> wrote in message <hsrrsd$o20$1(a)fred.mathworks.com>... > > I see. If Jos is correct, then you can also do this with a slight modification of the solution I gave earlier. > > > > > > [m,n] = size(A); > > Rr = npermutek(1:n,m); % The "Row-Rank" matrix. > > G = A((Rr-1)*m+repmat(1:m,n^m,1)); > > > > IIRC, COMBN and NPERMUTEK do the same thing using different methods. > > Hi, > I would like to ask something related to same thing. > If we have 9 numbers and we would like to assign one of the numbers below how can we look at each possibilities for example > 1st number can be 1 or 4 > 2nd number can be 1 or 4 > 3rd number can be 4 > 4th number can be 1 or 2 or 3 > 5th number can be 1 or 2 or 3 > 6th number can be 1 or 2 or 3 > 7th number can be 3 > 8th number can be 2 or 3 > 9th number can be 1 or 2 or 3 > how can we construct 2*2*1*3*3*3*1*2*3(648) numbers? > You can use NDGRID as following: c={[1 4] [1 4] 4 [1 2 3] [1 2 3] [1 2 3] 3 [2 3] [1 2 3]} n = length(c); [c{:}]=ndgrid(c{:}); c=cat(n+1,c{:}); c = reshape(c,[],n) % 648 combinations of 9 numbers % Bruno
|
Pages: 1 Prev: Image compression Next: basic problem with simulink |