Prev: find vector that is orthogonal to all columns of a matrix
Next: Simulink XY graph motion circle
From: Erik Andersson on 5 May 2010 08:19 Hello! I've would like to create a matrix 1000*3 i dimension which has all the combinations of the numbers 1 to 10 in it, i.e 1 1 1 1 1 2 .. . . 1 1 10 1 2 1 1 2 2 .. . . 1 2 10 1 3 1 And so on... Someone?
From: Sean on 5 May 2010 09:26 "Erik Andersson" <annerk02(a)student.umu.se> wrote in message <hrrnnq$mpa$1(a)fred.mathworks.com>... > Hello! > I've would like to create a matrix 1000*3 i dimension which has all the combinations of the numbers 1 to 10 in it, i.e > > 1 1 1 > 1 1 2 > . . . > 1 1 10 > 1 2 1 > 1 2 2 > . . . > 1 2 10 > 1 3 1 > And so on... > > Someone? One way: >>special_matrix = [ones(1000,1),sort(repmat([1:10]',100,1)) ,repmat([1:10]',100,1)];
From: Sean on 5 May 2010 09:32 "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <hrrrlc$cjo$1(a)fred.mathworks.com>... > "Erik Andersson" <annerk02(a)student.umu.se> wrote in message <hrrnnq$mpa$1(a)fred.mathworks.com>... > > Hello! > > I've would like to create a matrix 1000*3 i dimension which has all the combinations of the numbers 1 to 10 in it, i.e > > > > 1 1 1 > > 1 1 2 > > . . . > > 1 1 10 > > 1 2 1 > > 1 2 2 > > . . . > > 1 2 10 > > 1 3 1 > > And so on... > > > > Someone? > > One way: > >>special_matrix = [ones(1000,1),sort(repmat([1:10]',100,1)) ,repmat([1:10]',100,1)]; That was wrong :( I meant this: special_matrix = [sort(repmat([1:10]',100,1)), repmat(sort(repmat([1:10]',10,1)),10,1) ,repmat([1:10]',100,1)];
From: Matt J on 5 May 2010 11:45 "Erik Andersson" <annerk02(a)student.umu.se> wrote in message <hrrnnq$mpa$1(a)fred.mathworks.com>... > Hello! > I've would like to create a matrix 1000*3 i dimension which has all the combinations of the numbers 1 to 10 in it, i.e ====================== [c3,c2,c1]=ndgrid(1:10,1:10,1:10); special_matrix=[c1(:),c2(:),c3(:)];
|
Pages: 1 Prev: find vector that is orthogonal to all columns of a matrix Next: Simulink XY graph motion circle |