The code you wrote is a bit obfuscated. One way to make this more clear is to do:
frac_value = find(xmin > 0 & xmin < 1);
What you are essentially doing is finding the indices of xmin
that are both greater than 0 and less than 1. Instead of using intersect
, just use find
.
If you want to find the positions of where these values lie, then the above code is perfectly acceptable. However, I suspect that this is not what you're intending due to the title of your post. If you want to find the actual fractional values, you need to index into xmin
with frac_value
instead:
values = xmin(frac_value);
However, I wouldn't use find
or intersect
here at all. What is more efficient and simpler is to use logical indexing without find
or intersect
(which I will argue is faster performance-wise):
values = xmin(xmin > 0 & xmin < 1);
values
should now contain the values of xmin
that are between 0 and 1, rather than the locations of them.