Info

This question is closed. Reopen it to edit or answer.

how to merge 2 excel files to get different values as result

1 view (last 30 days)
i need to merge 2 excel files which are having different values. if their any existence of similar values. the results has to get display.
  1 Comment
Jan
Jan on 11 Aug 2017
Please post more details. Currently it is not possible to answer this. Do you really mean Excel files? Or are you able to import the data alreadfy to Matlab?

Answers (1)

Ahmed raafat
Ahmed raafat on 11 Aug 2017
Edited: Ahmed raafat on 11 Aug 2017
simple method is to read and save the two excels in 2 variables
x1=xlsread('Sheet1.xls');
x2=xlsread('sheet2.xls');
if size(x1,1)==size(x2,1) % check if thy have same rows
if size(x1,2)==size(x2,2) % check if they have same coulmns
z=x1-x2;
r=find(z==0); % find values that equals zero
zx=z(r); % choose them
disp(z) % display them
end
end
or if size of x1 and x2 not equal
same_values=[];
for i=1:size(x1,1)
for j=1:size(x2,2);
r=find(x2==x1(i,j));
if length(r)>0
same_values(end+1)=x1(i,j);
end
end
end
disp(same_values)

Community Treasure Hunt

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

Start Hunting!