creating a new column with three columns
    15 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Prakhar Modi
 le 25 Juin 2019
  
    
    
    
    
    Commenté : Prakhar Modi
 le 25 Juin 2019
            hello everyone,
i have three columns with 25 rows each. Now I want to merge all the three columns to one in a way that the first three rows will be the 1st values of all the three columns.
for ex: col_1,    col_2    col_3                    I need New merge col
            25        22            23                                25
            26        25            20                               22    
            24        28            30                                23
                                                                               26                and so on
so at last i will get one column with total of 75 rows
thanks in advance.
0 commentaires
Réponse acceptée
  Himanshu Rai
      
 le 25 Juin 2019
        Use this
X = reshape(X', [75, 1])
11 commentaires
  Himanshu Rai
      
 le 25 Juin 2019
				Use this (here X is the new modified matrix after the above operations)
X = reshape(X, [3, 25]);
X = X';
a = X(:, 1);
b = X(:, 2);
c = X(:, 3);
Plus de réponses (2)
  Pullak Barik
      
 le 25 Juin 2019
        
      Modifié(e) : Pullak Barik
      
 le 25 Juin 2019
  
      I will proceed in the following way-
1) Merge col_1, col_2, col_3 into a single matrix.
2) Reshape the transpose of the array.
The following code does the same-
res = reshape([col_1 col_2 col_3].', [], 1)
2 commentaires
  Pullak Barik
      
 le 25 Juin 2019
				Are your col_1, col_2 and col_3 variables stored as column vectors or row vectors?
Voir également
Catégories
				En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
			
	Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



