Asked by gabriel rios
on 11 Feb 2019

I have a matrix, I want all values inside the matrix greater than 2*pi to be subtracted by 2*pi, all values less than 0 to have 2*pi be added to them. Other terms stay constant as they are.

I have tried code below, but it does nothing. (I tried to change the theta4 > 2pi, then theta4 = 0 and nothing happened to my graph, althought some values are clearly above 0)

Theta4 is my matrix "[1x111] double" with "random" numbers.

I am not an expert in matlab, and some explination would be great.

%{

if theta4 > 2*pi

theta4 = theta4 - 2*pi;

elseif theta4 < 0

theta4 = theta4 + 2*pi ;

else

theta4= theta4 ;

end

%}

Answer by John D'Errico
on 11 Feb 2019

Accepted Answer

Theta4 = mod(Theta4,2*pi);

gabriel rios
on 11 Feb 2019

I do think this is, all values minized. I don't know how, but Ill take it!

Thanks sir

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Geoff Hayes (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/444239-i-have-a-matrix-i-want-all-values-inside-the-matrix-greater-than-2-pi-to-be-subtracted-by-2-pi-all#comment_669793

## gabriel rios (view profile)

Direct link to this comment:https://de.mathworks.com/matlabcentral/answers/444239-i-have-a-matrix-i-want-all-values-inside-the-matrix-greater-than-2-pi-to-be-subtracted-by-2-pi-all#comment_669943

Sign in to comment.