Data manipulation question, need some help!!
Mostra commenti meno recenti
Guys, I really need some help here. I got stuck for a long time.
1. How am I supposed to create a matrix that has two columns, the format of the first one is string, and the second is numerical?
Say a = ['1';'2';'3'], b = [4,5,6], I need to create a matrix like c =
1 4
2 5
3 6
I tried to use c = {a,b}, but the answer is c = [3x1 char] [3x1 double]
2. A =
'15' 3854
'10' 6331
'10' 4324
'20' 3874
'25' 4321
'15' 6835
'10' 3321
'15' 3821
'20' 9324
I need to sum the 2nd column according to the 1st column and create a new matrix. E.g, for '10', I should sum up (6331,4324,3321) , the final result should be
B =
'10' 13976
'15' 10689
'20' 13198
'25' 4321
Any opinion is welcomed!
Risposta accettata
Più risposte (1)
Walter Roberson
il 18 Giu 2012
Ta = cellstr(a);
Tb = num2cell(b);
c = [Ta(:), Tb(:)];
1 Commento
Xiao Tang
il 18 Giu 2012
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!