NewArray = complex(real(YourArray), abs(imag(YourArray)));
NewArray = real(YourArray) + 1i .* abs(imag(YourArray));
Using complex() should be slightly more efficient.
There is a very slight difference in the results between the two: In the case where the imaginary components of the array are all 0, then the + 1i .* form would be adding 1i .* 0 which would all vanish and the end result in NewArray would be marked as entirely real-valued. But if you use complex() then even if the final result has all-zero in the imaginary component, the result will be marked as complex, and will have storage allocated for the complex part.
For most purposes, whether the all-zero imaginary part is stored or not makes no difference. But it can make a difference when you are calling library routines that are expecting a complex array, especially if you are expecting them to update the array "in-place"