## Could anyone help me to solve the following issue

### jaah navi (view profile)

on 3 Jun 2019
Latest activity Commented on by KSSV

### KSSV (view profile)

on 3 Jun 2019
Code:
a = [1 2 3 4 5;
6 7 8 9 10]
a_rand = a(randperm(length(a)))
When i run the above two commands it executes and gives the following result
a_rand = 3 6 2 7 1
But in this result i can get only one row .
Coud anyone help me how to get two rows with the left out numbers displaying at the second row.

### KSSV (view profile)

on 3 Jun 2019

a = [1 2 3 4 5;
6 7 8 9 10] ;
idx1 = (randperm(length(a))) ;
idx2 = setdiff(1:numel(a),idx1) ;
iwant = [a(idx1) ; a(idx2)]

Show 1 older comment
KSSV

### KSSV (view profile)

on 3 Jun 2019
iwant = reshape(a(randperm(numel(a))),size(a)) ;
jaah navi

### jaah navi (view profile)

on 3 Jun 2019
reshape should be done with respect to the elements present in its own column.But when i used the above command it reshapes with respect to different column.could you please help me to solve this.
KSSV

### KSSV (view profile)

on 3 Jun 2019
[m,n] = size(a) ;
b = a ;
for i = 1:m
idx = randperm(n) ;
b(i,:) = a(i,idx) ;
end

on 3 Jun 2019

a = [1 2 3 4 5; 6 7 8 9 10]
a_rand = a(randperm(length(a)))
a_rand = [a_rand; a(~ismember(a(:),a_rand(:)))']

jaah navi

### jaah navi (view profile)

on 3 Jun 2019
It works fine for two rows,but how it can done for n number of rows with repect to the above mentioned matrix
a=[4.7908 5.0104 5.1329 5.3186 5.3094 5.3070 5.4452 5.5001;
0.0958 0.0994 0 0 0.1848 0.2020 0.1851 0.2146;
0.0848 0 0.1469 0.1859 0.1767 0.1854 0.1856 0.1648;
0 0 0 0 0 0 0 0;
0 0.0896 0.1619 0.1351 0 0 0 0;
0 0 0 0 0 0 0 0];

on 3 Jun 2019
KSSVs reahape seems the best solution for your problem, unless you are looking for some other output
jaah navi

### jaah navi (view profile)

on 3 Jun 2019
but reshape makes use of reshaping from different column elements.
I want to reshape the elements present in its respective column.
For example
if
a= [4.7908 5.0104 5.1329 5.3186 5.3094 5.3070 5.4452 5.5001;
0.0958 0.0994 0 0 0.1848 0.2020 0.1851 0.2146;
0.0848 0 0.1469 0.1859 0.1767 0.1854 0.1856 0.1648;
0 0 0 0 0 0 0 0;
0 0.0896 0.1619 0.1351 0 0 0 0;
0 0 0 0 0 0 0 0]
the the output shoud be
a= [4.7908 0 0 5.3186 5.3094 5.3070 5.4452 0;
0 0.0994 0 0 0 0 0.1851 0.2146;
0.0848 0 0.1469 0.1859 0 0.1854 0 0.1648;
0.0958 0 0 0 0 0 0 5.5001;
0 0.0896 0.1619 0 0.1848 0.2020 0 0;
0 5.0104 5.1329 0.1351 0.1767 0 0.1856 0]
in the following random manner.