Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Guillaume
Guillaume el 19 de Mayo de 2016
Editada: Guillaume el 19 de Mayo de 2016
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.

Más respuestas (0)

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by