Search for a range in a column

I need to search for each individual number in a column with a plus/minus range and see if that range is present in another column. Is this posible with Matlab.

2 Comments

Your question is not very clear at all (at least to me). Please spend more than 1 minute and 2 sentences to describe what you are trying to do. A small example of an input and output would be very helpful.
Thank you for comming back to me. The imput would be two columns (A and B), both columns contain masses. I need to see if there are duplicate numbers (masses) in B, but within a plus minus range. For example if column A has 70.12543 and column B contains 70.12563 I would need to highlight or identify that cell from column B as a duplicate. The tolerance is +/- 0.00001. Hope this helps, let me know if this is not clear.

Sign in to comment.

Answers (1)

m=yourMatrix;
t=.00001;
for k=1:size(m,1)
c{k}=find(m(:,2)>=m(k,1)-t&m(:,2)<=m(k,1)+t);%use cell array if there can be more than one
end

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 29 Oct 2021

Answered:

on 1 Nov 2021

Community Treasure Hunt

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

Start Hunting!