MATLAB Answers

Compare a column in two different excel-sheet

조회 수: 3(최근 30일)
Khal Genidy
Khal Genidy 2021년 7월 27일
답변: dpb 2021년 7월 27일
I would like to have an idea on how to compare a column in two different excel sheets.
ex,
sheet 1 column A Sheet 2 column A
5 4.4
5 4.6
5 3
5 7
What i want is to find the columns that have differences in numbers between the two sheets and if column A in sheet 2 is +/- 1 of column A in sheet 1 then give an output of "good"
if more that +/-1 give an output "bad"
Thanks,

답변(1개)

dpb
dpb 2021년 7월 27일
Just read both sheets --
CODES=categorical({'bad','good'}).'; % the output categories
A1=readmatrix('WorkbookFileName.xlsx','Sheet',1);
A2=readmatrix('WorkbookFileName.xlsx','Sheet',2);
isOK=CODES((abs(A2-A1)<=1)+1);

Community Treasure Hunt

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

Start Hunting!

Translated by