Create an array containing the values of a cell type matrix corresponding to each of the examples contained in other cell type matrix.

2 次查看(过去 30 天)
I have a data matrix 17000x4 cell type and other cell matrix type 49000x38 containing both text and numerical data . The first column of the second matrix contains 49000 numerical labels elements while the first column of the first array contains 17000 examples of some of these labels . My goal is to create an array containing the values of the columns 2:38 the second matrix corresponding to each of the examples 17000 . In short , I want to look for each example corresponding feature vector contained in the second matrix.
I want to do somthing like this but using vectors instead single values for each key: http://es.mathworks.com/help/matlab/matlab_prog/creating-a-map-object.html#brq_zd0-1

采纳的回答

Guillaume
Guillaume 2016-5-19
编辑:Guillaume 2016-5-19
The code you've posted is equivalent to:
[numA, ~, A] = xlsread('Data.xlsx',1);
[numB, ~, B] = xlsread('Data.xlsx',2);
[found, rows] = ismember(numA(:, 1), numB(:, 1));
%option that keeps rows of A not found in B:
out = [A, cell(size(A, 1), size(B, 2)-1)];
out(found, size(A, 2)+1:end) = B(rows, 2:end)
%option that discard rows of A not found in B (simpler)
out = [A(found, :), B(rows, 2:end)]
except this is more robust since it'll work even if a key is duplicated.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by