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.
1 次查看(过去 30 天)
显示 更早的评论
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
%}
2 个评论
Geoff Hayes
2019-2-11
gabriel - suppose your matrix has 4*pi as one of its elements. If we subtract 2*pi, then we are left with 2*pi. Should we subtract 2*pi again (and continue to do so) until the result is less than 2*pi?
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!