combine cells with unequal dimensions
Show older comments
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 Comments
Amr Hashem
on 25 Jul 2015
Amr Hashem
on 25 Jul 2015
Walter Roberson
on 25 Jul 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
on 25 Jul 2015
Edited: Azzi Abdelmalek
on 25 Jul 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
on 25 Jul 2015
Image Analyst
on 25 Jul 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
on 25 Jul 2015
Edited: Amr Hashem
on 25 Jul 2015
Amr Hashem
on 25 Jul 2015
Edited: Amr Hashem
on 25 Jul 2015
Answers (1)
Amr Hashem
on 26 Jul 2015
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
