¿whats this?
I don't really get the purpose of this:
if tf
tf = ~any((theta<(-2*pi))|(theta>(2*pi)));
end
there are 2 loops between -2pi : 2pi, if you only want to have one value for each angle, and I give you data between -2pi:2pi, you can have two different values for each angle.