MATLAB: Keep the negative value while squaring

MATLAB

Acc_Rocket(t) = (Thrust - weight - drag*Velocity(t)^2)./mass;
when the velocity is negative, the drag should be positive, but squaring the velocity makes the drag negative again, is there a way to make the velocity value keep its negative sign even when squared.

Best Answer

Change this
Velocity(t)^2
to this
abs(Velocity(t)) * Velocity(t)
Related Question