From: ratnesh kumar on 27 Jan 2010 04:11 hi, i have numbers like 1 2 3 4 5 motive is to make matrix like 1 2 1 3 1 4 1 5 1 2 3 1 2 4 1 2 5 1 3 4 1 3 5 1 4 5 %then 1 2 4 5 these 12345 is maybe any numbers suppose 21 45 67 33 22.number of elements is 5 it may vary to any length 21 45 21 67 21 33 21 22 21 45 67 21 45 33 21 45 22 21 67 33 21 67 22 21 33 22 21 45 33 22
From: Walter Roberson on 27 Jan 2010 10:07 ratnesh kumar wrote: > i have numbers like 1 2 3 4 5 > motive is to make matrix like > > 1 2 > 1 3 > 1 4 > 1 5 > 1 2 3 > 1 2 4 > 1 2 5 > 1 3 4 > 1 3 5 > 1 4 5 %then > 1 2 4 5 Matlab does not permit matrices to have varying number of elements across the rows. You will have to use a cell array instead of a numeric matrix.
From: ratnesh kumar on 27 Jan 2010 12:45 Walter Roberson <roberson(a)hushmail.com> wrote in message <hjpkqn$jia$1(a)canopus.cc.umanitoba.ca>... > ratnesh kumar wrote: > > > i have numbers like 1 2 3 4 5 > > motive is to make matrix like > > > > 1 2 > > 1 3 > > 1 4 > > 1 5 > > 1 2 3 > > 1 2 4 > > 1 2 5 > > 1 3 4 > > 1 3 5 > > 1 4 5 %then > > 1 2 4 5 > > > Matlab does not permit matrices to have varying number of elements > across the rows. You will have to use a cell array instead of a numeric > matrix. hi, thanks if i will do one matrix contains two column another contains three column and same for the rest.the there will be the possibility numbers having all possibilities with one element.
From: Nathan on 27 Jan 2010 16:47 On Jan 27, 9:45 am, "ratnesh kumar" <iam_ratn...(a)yahoo.co.in> wrote: > Walter Roberson <rober...(a)hushmail.com> wrote in message <hjpkqn$ji...(a)canopus.cc.umanitoba.ca>... > > ratnesh kumar wrote: > > > > i have numbers like 1 2 3 4 5 > > > motive is to make matrix like > > > > 1 2 > > > 1 3 > > > 1 4 > > > 1 5 > > > 1 2 3 > > > 1 2 4 > > > 1 2 5 > > > 1 3 4 > > > 1 3 5 > > > 1 4 5 %then > > > 1 2 4 5 > > > Matlab does not permit matrices to have varying number of elements > > across the rows. You will have to use a cell array instead of a numeric > > matrix. > > hi, > thanks if i will do one matrix contains two column another contains three column and same for the rest.the there will be the possibility numbers having all possibilities with one element. doc nchoosek That should be a starting point for you. -Nathan
From: ratnesh kumar on 3 Feb 2010 14:59
hi, thanks for giving me suggestions.but nchoose create problem when their is large string.it is slow also.for S=[S3(1:15)] this is ok but when iam using S=[S1,S2,S3] matlab gives problem of "out of memory". iam using these code same problem occured S1 =[3 20 21 22 23 25 26 27 28 29 30 62 66 69 71 72 74 75 77 80 82 83 84 85 86 89]; S2=[90 92 96 99 101 103 105 107 111 114 115 116 117 118 119 124 125 127 129 131 137 141 144 24 67 68]; S3=[70 87 88 95 98 100 104 110 112 121 134]; %for S=[S3(1:5)] %%%*******change N = numel(S); S = S(:).' ; % make the set a row vector, for uniform output p2=2.^(N-1:-1:0); % This part of the formula can be taken out of the loop nm=(2^(N-1)) for i=1:nm, W{i}= S(bitget((2*i-1)*p2,N) > 0) ; end celldisp(W) provide me solution thanks |