MATLAB: How to retain only the positive root of a quadratic equation

roots of quadratic equation

I was wondering if there is any Matlab function that would allow me to retain only the positive root of a quadratic equation. I want to use that function along with the 'roots' function to solve n number of quadratic equations to get n number of positive roots.
x=zeros(1,n)
for i=1:n
x(i)=function(roots([a(i) b(i) c(i)]))
end

Best Answer

To only get the positive elements of array a:
>>a = [-2.5 0 2.5 -3.5 1];
>>apos = a(a>=0)
apos =
0 2.5000 1.0000