I'd suggest adding test cases in which xlow<0 (and maybe also xhigh<0).
How to find the position of an element in a vector without using the find function
2482 Solvers
Convert a numerical matrix into a cell array of strings
469 Solvers
253 Solvers
2583 Solvers
667 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!