I'm attempting to find values in the array x
which are <= p
, and perform one set of operations on those specific values where the condition holds true, and another set of operations otherwise. Below is essentially what I am trying to achieve, and I am aware that it doesn't work. Is there a way to achieve what I want via vector operations rather than using a for loop to iterate through each value?
if x <= p
y = (m/(p^2)).*(2*p.*x - x.^2);
theta = atan((m/(p)).*(p - x));
else
y = (m/((5-p)^2)).*((1-p) + 2*p.*x - x.^2)
theta = atan((2*m/((1-p)^2)).*(p - x));
end