In: Computer Science
Write a Matlab/SciLab function that accepts inputs as degrees and computes the equivalent within the interval 0 to 360.
function de=equivalent(d) For example, equivalent(540) = 180 equivalent(-30) = 330
File name:- equivalent.m
Matlab program:- in Editor
function de=equivalent(d) %d
is input for function in degrees
if(d<0)
while(d<0)
d=360+d; %while d is
lessthan zero add 360 for d
end
end
if(d>360)
while(d>360)
d=d-360; %while d is
greaterthan zero substract 360 from d
end
end
de=d;
%return the remaining d
end
Output:- in Command window
>> de=equivalent(550)
de =
190
>> de=equivalent(540)
de =
180
>> de=equivalent(-30)
de =
330
>> de=equivalent(90)
de =
90
>>