How can a matrix of randperm be generated with variable n*m?
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I want to generate a matrix of n*m size, which looks like 
 where 
n=3 
m=4
A=[randperm(m); randperm(m);randperm(m);]
These value may change with problem size. How can i generate this matrix since n and m vary? No loop please!
0 Commenti
Risposta accettata
  John D'Errico
      
      
 il 12 Feb 2020
        SImpler than you think.
M = 4;
N = 3;
[~,A] = sort(rand(M,N),1)
A =
     1     1     3
     4     2     1
     2     3     4
     3     4     2
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


