Transforming Result to Meaningful Information
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Walter Roberson
il 9 Dic 2011
Using Andrei's variables:
[tf, idx] = ismember([M{:,1}], [A{:,1}]);
M(tf, 1) = A(idx(tf), 2);
0 Commenti
Andrei Bobrov
il 9 Dic 2011
[j1,j1] = sortrows(M,1)
[i1,i1] = sortrows(A,1)
ji = sortrows([j1 i1],1)
M(:,1) = A(ji(:,2),2)
0 Commenti
Vedere anche
Categorie
Scopri di più su Spreadsheets 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!