Transforming Result to Meaningful Information
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Walter Roberson
el 9 de Dic. de 2011
Using Andrei's variables:
[tf, idx] = ismember([M{:,1}], [A{:,1}]);
M(tf, 1) = A(idx(tf), 2);
0 comentarios
Andrei Bobrov
el 9 de Dic. de 2011
[j1,j1] = sortrows(M,1)
[i1,i1] = sortrows(A,1)
ji = sortrows([j1 i1],1)
M(:,1) = A(ji(:,2),2)
0 comentarios
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!