how to display a value in first column the second column number of times?
    2 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    johnson saldanha
 le 10 Déc 2018
  
    
    
    
    
    Commenté : johnson saldanha
 le 10 Déc 2018
            suppose i have a column vector x=[1 2 3 4]; and y=[2  3  3.5  4]
 i want the output as xy=[1 1 2 2 2 3 3 3 3 4 4 4 4];
the number 3.5 can be rounded off to a whole number. here ive taken it as 4.
0 commentaires
Réponse acceptée
  Walter Roberson
      
      
 le 10 Déc 2018
        
      Modifié(e) : Walter Roberson
      
      
 le 10 Déc 2018
  
      repelem(x, round(y))
7 commentaires
  Walter Roberson
      
      
 le 10 Déc 2018
				cell2mat(arrayfun(@(v, n) v(ones(n,1)), x, round(y), 'uniform', 0))   %assumes inputs are column vectors
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Annotations dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

