필터 지우기
필터 지우기

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