Hello everyone, I want to restrict the domain of a vector to return it to a smaller data set. For example, X between 2 and 7
5 次查看（过去 30 天）
Perfect use for my utility function iswithin
2 3 4 5 6 7
where iswithin is
% returns T for values within range of input
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
It's just "syntactic sugar" remove the logical expression out of the main code for legibility, but it's extremely handy for shortening multiple range selections or the like or using it in arguments to other functions instead of building temporaries.
Copy to an m-file named "iswithin.m" and place wherever on your MATLABPATH you keep such handy little goodies where they're available for everybody. I create a "Utilities" subdirectory and insert in second in line in my MATLABPATH behind my current working directory.