Define y on all the execution paths. Consider this example:
If x is in the interval [1, 10] then out never gets assigned a value. This is a slightly different error message than the one you're receiving but it's the same cause. In the example above I'd probably add an else statement defining the value out should have if x is neither less than 1 nor greater than 10 or I would assign out that "default" value before the if statement.
Of course, if you're operating on a vector of data the same general principle applies but you need to take into account how if behaves when given a non-scalar condition.