From the documentation "if expression, statements, end evaluates an expression, and executes a group of statements when the expression is true. An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). Otherwise, the expression is false." So the body of your if statement would only execute if all the elements of 49.9<v<51.5 were true.
But there's another issue here. Your condition does not mean what you think it means.
49.9 < v < 51.1 is equivalent to (49.9 < v) < 51.1. The expression inside the parentheses is a logical vector containing only false (equivalent of 0) and true (equivalent of 1) values. Because both 0 and 1 are less than 51.1 your condition is always satisfied.
To detect which elements of v are in the range (49.9, 51.1) use two logical operations combined with an and (the & operator.)
v= (0:5:50)
mask = (49.9 < v) & (v < 51.1) % All elements are false except the last which is true
q = v(mask)
You can use this mask to index and retrieve elements from v, like I did to assign the 50 from it to the variable q, or you can use it to assign to a vector. These are examples of logical indexing
z = zeros(size(v));
z(~mask) = 99;
z(mask) = 42