From: Judith Machts on 18 Mar 2010 07:54 hello, i have problems using the command "randperm". i want to randomize a cell array, containing pictures. cell_array = {'1.jpg',........'80.jpg'}; now the command cell_array = randperm(length(cell_array)) creates random numbers, but i can´t use the random numbers to re-index my cell-array. well probably it´s quite simple...
From: Wayne King on 18 Mar 2010 08:15 "Judith Machts" <kartoffelmus(a)googlemail.com> wrote in message <hnt48s$bor$1(a)fred.mathworks.com>... > hello, > > i have problems using the command "randperm". i want to randomize a cell array, containing pictures. > cell_array = {'1.jpg',........'80.jpg'}; > now the command > cell_array = randperm(length(cell_array)) creates random numbers, but i can´t use the random numbers to re-index my cell-array. > well probably it´s quite simple... Hi Judith, what's wrong with: CellArray={'1.jpg','2.jpg','3.jpg','4.jpg'}; Perm1 = randperm(length(CellArray)); NewCell=CellArray(Perm1); Wayne
From: Judith Machts on 18 Mar 2010 08:24 "Wayne King" <wmkingty(a)gmail.com> wrote in message <hnt5gb$25i$1(a)fred.mathworks.com>... > "Judith Machts" <kartoffelmus(a)googlemail.com> wrote in message <hnt48s$bor$1(a)fred.mathworks.com>... > > hello, > > > > i have problems using the command "randperm". i want to randomize a cell array, containing pictures. > > cell_array = {'1.jpg',........'80.jpg'}; > > now the command > > cell_array = randperm(length(cell_array)) creates random numbers, but i can´t use the random numbers to re-index my cell-array. > > well probably it´s quite simple... > > Hi Judith, what's wrong with: > > CellArray={'1.jpg','2.jpg','3.jpg','4.jpg'}; > Perm1 = randperm(length(CellArray)); > NewCell=CellArray(Perm1); > > Wayne Ah thank you so much. I was working on it too long, so i didn´t see the simple solution....thanks a lot :) judith
From: Matt Fig on 18 Mar 2010 08:39 c = {'1','2','3'} c = c(randperm(3))
From: Jos (10584) on 18 Mar 2010 09:08 "Judith Machts" <kartoffelmus(a)googlemail.com> wrote in message <hnt613$ain$1(a)fred.mathworks.com>... > "Wayne King" <wmkingty(a)gmail.com> wrote in message <hnt5gb$25i$1(a)fred.mathworks.com>... > > "Judith Machts" <kartoffelmus(a)googlemail.com> wrote in message <hnt48s$bor$1(a)fred.mathworks.com>... > > > hello, > > > > > > i have problems using the command "randperm". i want to randomize a cell array, containing pictures. > > > cell_array = {'1.jpg',........'80.jpg'}; > > > now the command > > > cell_array = randperm(length(cell_array)) creates random numbers, but i can´t use the random numbers to re-index my cell-array. > > > well probably it´s quite simple... > > > > Hi Judith, what's wrong with: > > > > CellArray={'1.jpg','2.jpg','3.jpg','4.jpg'}; > > Perm1 = randperm(length(CellArray)); > > NewCell=CellArray(Perm1); > > > > Wayne > > Ah thank you so much. I was working on it too long, so i didn´t see the simple solution....thanks a lot :) > judith You might be interested in SHAKE and/or RANDSWAP both to be found on the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/12621-randswap http://www.mathworks.com/matlabcentral/fileexchange/10067-shake For instance: CellArray={'1.jpg','2.jpg','3.jpg','4.jpg'}; C = shake(CellArray) % C = { '2.jpg' '3.jpg' '1.jpg' '4.jpg' } Jos
|
Pages: 1 Prev: Object length-width measurement Next: randperm cell array |