フィルターのクリア

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 Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by