Created
January 9, 2018 16:22
-
-
Save Turux/46ed2e41bfd7795b3cfbbadf0b568385 to your computer and use it in GitHub Desktop.
A MATLAB function that converts a 1D array from degrees to revolutions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ revs ] = deg2revs( deg ) | |
% @Brief: A function that converts a 1D array from degrees to revolutions | |
% @Param: deg -> 1D array of angles expressed in degrees | |
% @Return: revs -> 1D array that counts how many revolutions have been | |
% completed. Starts from 1 for future grouping. | |
% A revolution | |
d = diff(deg); | |
revs = ones(length(deg),1); | |
for i = 1:(length(deg)-1) | |
if(d(i) < -90) | |
revs(i+1) = revs(i)+1; | |
else | |
revs(i+1) = revs(i); | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment