Transforming Result to Meaningful Information
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
Walter Roberson
on 9 Dec 2011
Using Andrei's variables:
[tf, idx] = ismember([M{:,1}], [A{:,1}]);
M(tf, 1) = A(idx(tf), 2);
0 Comments
Andrei Bobrov
on 9 Dec 2011
[j1,j1] = sortrows(M,1)
[i1,i1] = sortrows(A,1)
ji = sortrows([j1 i1],1)
M(:,1) = A(ji(:,2),2)
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!