removing rows in a loop of excel

2 views (last 30 days)
Tian Tian
Tian Tian on 15 Feb 2018
Edited: Birdman on 15 Feb 2018
Hi, I want to compare paired excels in a folder. In the loop, i hope to select rows with columnB similar to previous one.
for i=1 : LengthB1 % B1 is the columnB from excel1
for j=1 : LengthB2 %B2 is the columnB from excel2
cellB1(i)=columnB1(i,1);
cellB2(j)=columnB2(j,1);
if cellB2(j)<=cellB1(i)*1.5 & cellB2>=cellB1*0.5
na=na+1
My questions are: 1) for i=1, j=5 and 10 both are good, but i want to get only one with the closest distance from B2 to B1 from j ; 2) for i=1, if j=5 is selected, then for i=2, i hope the loop of j can skip j=5. Can anyone give me a hand? Many thanks in advance.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!