why the give code doesn’t meet my requirements?
I want to Wrap angles to the range [-180, 180] degrees. For this I have the following code:
function wrapped_angles = wrapTo180(angles)
% Wrap angles to the range [-180, 180] degrees
wrapped_angles = mod(angles + 180, 360) – 180;
end
Likewise, I want Wrap angles to the range [-90, 90] degrees. For this I have the following code:
function wrapped_angles = wrapTo90(angles)
% Wrap angles to the range [-90, 90] degrees
wrapped_angles = mod(angles + 90, 180) – 90;
end
The 2nd function works correctly but the 1st one doesn’t work correctly. Why it is so?I want to Wrap angles to the range [-180, 180] degrees. For this I have the following code:
function wrapped_angles = wrapTo180(angles)
% Wrap angles to the range [-180, 180] degrees
wrapped_angles = mod(angles + 180, 360) – 180;
end
Likewise, I want Wrap angles to the range [-90, 90] degrees. For this I have the following code:
function wrapped_angles = wrapTo90(angles)
% Wrap angles to the range [-90, 90] degrees
wrapped_angles = mod(angles + 90, 180) – 90;
end
The 2nd function works correctly but the 1st one doesn’t work correctly. Why it is so? I want to Wrap angles to the range [-180, 180] degrees. For this I have the following code:
function wrapped_angles = wrapTo180(angles)
% Wrap angles to the range [-180, 180] degrees
wrapped_angles = mod(angles + 180, 360) – 180;
end
Likewise, I want Wrap angles to the range [-90, 90] degrees. For this I have the following code:
function wrapped_angles = wrapTo90(angles)
% Wrap angles to the range [-90, 90] degrees
wrapped_angles = mod(angles + 90, 180) – 90;
end
The 2nd function works correctly but the 1st one doesn’t work correctly. Why it is so? wrapping angles within a range, logic is correct but, not working, though one is working MATLAB Answers — New Questions