joining of 2 matricces
    9 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    pradeep kumar
 il 5 Set 2014
  
    
    
    
    
    Commentato: pradeep kumar
 il 5 Set 2014
            hellow everyone . i have 2 following matricces .Say A =['dog' ;'cat' ; 'cow'] . B= [1;2;3] . now i want to get a matrix C such that C=['dog' 1;'cat' 2;'cow' 3]. please help me out.
0 Commenti
Risposta accettata
  Guillaume
      
      
 il 5 Set 2014
        It's not possible. A is a matrix of char, B is a matrix of doubles. All elements of a matrix must be of the same type.
What you can do is put them into a cell array, but the syntax for accessing elements is different:
C = [num2cell(A, 2) num2cell(B)]
%access elements of C:
cat = C{2, 1};
three = C{3, 2};
If A and B were of the same type and size (A=[4;5;6], B=[1;2;3]), you could just concatenate them
C = [A B];
0 Commenti
Più risposte (1)
  Yawar Rehman
 il 5 Set 2014
         A = ['dog '; 'cat '; 'cow '];
 B = [1 ; 2 ; 3]; B = num2str(B);
 comb = [A B]
Vedere anche
Categorie
				Scopri di più su Performance and Memory 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!

