combine cells with unequal dimensions
Afficher commentaires plus anciens
i have two tables ( A 13*52 cell & B 19*75 cell )
A

& B

first column in each(A & B) has a some duplicated numbers ( 4368042 - 4324685 - 4321114 )
i want to found duplicated numbers in first columns and if exist copy all rows of it
to a new table consists of [ A , New B]
New B = only duplicated numbers ( 4368042 - 4324685 - 432111)
i write this code:
clear all; clc
tic
[ndata2 text2 alldata2] = xlsread('datecode.xlsx','devtex');
[ndata text alldata] = xlsread('datecode.xlsx','mdr');
[R1,C1]=size(alldata2);
[R2,C2]=size(alldata);
colsize=max(C1,C2);
for i=1:size(alldata,1)
for j=1:R1 %length(Defs)
if alldata2{j,1}==alldata{i,1}
data1(j,:)=alldata(i,:);
end
end
end
new_table=[alldata2,data1];
but i got an error in the last line :
CAT arguments dimensions are not consistent.
Error in ==> mdrtry at 37
new_table=[alldata2,data1];
how i can solve this ?
8 commentaires
Amr Hashem
le 25 Juil 2015
Amr Hashem
le 25 Juil 2015
Walter Roberson
le 25 Juil 2015
You can use the technique I showed in http://uk.mathworks.com/matlabcentral/answers/231118#answer_187145 to determine the lengths and pad the shorter entries.
Azzi Abdelmalek
le 25 Juil 2015
Modifié(e) : Azzi Abdelmalek
le 25 Juil 2015
In your example, 4368042 doesn't exist in B, and how to will you concatenate A and new_B? They haven't the same number of columns
Amr Hashem
le 25 Juil 2015
Image Analyst
le 25 Juil 2015
Why don't you just attach a .mat file with A and B in it so people can help you much more efficiently and effectively?
Amr Hashem
le 25 Juil 2015
Modifié(e) : Amr Hashem
le 25 Juil 2015
Amr Hashem
le 25 Juil 2015
Modifié(e) : Amr Hashem
le 25 Juil 2015
Réponses (1)
Amr Hashem
le 26 Juil 2015
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

