Oops, I forgot to include that function. I'll fix it, but in the meantime, here it is:
% Returns the index and the value of the element of vector x that is closest to val
% If more than one element is equally close, returns vectors of indicies and values
% Tom O'Haver (firstname.lastname@example.org) October 2006
% Examples: If x=[1 2 4 3 5 9 6 4 5 3 1], then val2ind(x,6)=7 and val2ind(x,5.1)=[5 9]
% [indices values]=val2ind(x,3.3) returns indices = [4 10] and values = [3 3]
Thanks so much for sharing this useful toolbox. I have a question here. when I tried to run ipeakdemo2.m or DemoFindPeaksb.m, it kept saying
??? Undefined function or method 'val2ind' for input arguments of type 'double'.
so how should do with this problem? Thanks for your help!