필터 지우기
필터 지우기

Cross reference from 2 excel files in Matlab

조회 수: 1 (최근 30일)
Matrix-Matlab
Matrix-Matlab 2017년 4월 22일
답변: Nikhil Sreekumar 2017년 4월 25일
Hello,
I have two excel documents which I have imported to matlab with xlsread.
Now my task is to take a destination code from file 1 and match it with a destination name from file 2. (screenshots of the two different files)
I hope someone is able to help me with some pointers on how to do this.
Thank you in advance - Emil

답변 (1개)

Nikhil Sreekumar
Nikhil Sreekumar 2017년 4월 25일
Hi there,
What exactly is it that you are meaning on saying match the two columns?
  • Comparing each row element in one with each row element in another?
  • Comparing corresponding row elements?
  • Comparing columns of different size?
If you doing xlsread and taking the raw data, then you can do something like this to do a corresponding element-wise comparison:
Case - Check if both columns same
[~, ~, raw1] = xlsread('data1.xlsx');
Destination1 = {raw1{:, 1}}; % column 1
[~, ~, raw2] = xlsread('data2.xlsx');
Destination2 = {raw2{:, 1}}; % column 1
isequal(Destination1, Destination2);
You can also check ismember function
Thanks
Nikhil

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by