Transforming Result to Meaningful Information
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a 5x4 cell array with contents as such:-
14 2 5 10
27 1 2 3
10 2 9 4
45 5 9 9
2 1 4 10
I then imported an excel file using the command:-
[~,~,A]=xlsread('filename')
The excel file has content as such:-
45 John
2 Bob
27 Alice
10 Ben
14 Peter
How can I transform the first column of the cell array to display the name instead of number (in accordance to the excel file's first column)?
0 commentaires
Réponses (2)
Walter Roberson
le 9 Déc 2011
Using Andrei's variables:
[tf, idx] = ismember([M{:,1}], [A{:,1}]);
M(tf, 1) = A(idx(tf), 2);
0 commentaires
Andrei Bobrov
le 9 Déc 2011
[j1,j1] = sortrows(M,1)
[i1,i1] = sortrows(A,1)
ji = sortrows([j1 i1],1)
M(:,1) = A(ji(:,2),2)
0 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets 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!