combine cells with unequal dimensions
이전 댓글 표시
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
Amr Hashem
2015년 7월 25일
Amr Hashem
2015년 7월 25일
Walter Roberson
2015년 7월 25일
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
2015년 7월 25일
편집: Azzi Abdelmalek
2015년 7월 25일
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
2015년 7월 25일
Image Analyst
2015년 7월 25일
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
2015년 7월 25일
편집: Amr Hashem
2015년 7월 25일
Amr Hashem
2015년 7월 25일
편집: Amr Hashem
2015년 7월 25일
답변 (1개)
Amr Hashem
2015년 7월 26일
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

