We don't have enough information about your variables. Whether you're giving a talk or writing a report or posting on a forum, always explicitly describe any variable you ever show. If a variable is not relevant, do not show it to us. If a variable is relevant, describe it.
To increase your chances of getting helpful responses, provide a picture of what you're trying to do and some simple working code that we can tinker with.
When I look at your code, all I see is not related to your question, but you can replace
sqrt(tempV(1)^2 + tempV(2)^2)
with
hypot(tempV(1),tempV(2))