loops - looping trouble in Matlab -


suppose matrix given d.

d=[1.32 4.354 6.78 4.56;     4.65 3.23  2.34 8.9;     2.32 7.65  4.98 2.78] 

i require pick values such no 2 values chosen same. want pick 5 values in increment of 1 using matlab.

for ii=1:5   % pick value 1 one such no 2 values chosen same end 

loop should function this:

  ii=1, d'=4.354   ii=2, d'=4.354 2.32 

it shouldn't :

   ii=2, d'=4.354 4.354  

just use randperm create linear index of 5 random non-repeating numbers:

d(randperm(numel(d),5)) 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -