Write a Matlab/SciLab function that accepts inputs as degrees and computes the equivalent within the interval...

Free

80.2K

Verified Solution

Question

Programming

Write a Matlab/SciLab function that accepts inputs as degreesand computes the equivalent within the interval 0 to 360.

function de=equivalent(d) For example, equivalent(540) = 180equivalent(-30) = 330

Answer & Explanation Solved by verified expert
4.0 Ratings (754 Votes)

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

>>


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students