Hi. I have a problem where I need to update the index value with a larger index if elements in A greater than B..
A = [2;7.5;9;10.5;15;14]; % Also can be in random numbers A and B are different in size
B = 5:5:50 % Fixed numbers
idx = ones(size(A,1),1; % Set to one if A less than B
for i = 1:size(A,1) [~,idx(i)] = ismembertol(A(i),B,0.05);end% Results
idx = [0;1;2;2;3;3]%Which I want to get
idx = [1;2;2,3,4,3]
Please help, and thanks in advance.
Best Answer