In: Mechanical Engineering
Create and complete a function M-file that will receive an input, ? , and output the corresponding conversion to radians within the range of a complete circle. For each 30? increment, the output should be displayed as a string, (i.e. pi/2 , pi/4 ,etc.), and any other degree to be displayed numerically.
I'm using Matlab, explanations are appreciated.
STEP1:
CREATING A FUNCTION IN MATLAB:
(Code starts below)
function angleradian =rad(Min,Max) %%creating function angle
radian in matlab%%
angledegrees=Min:30:Max
angleradian=(angledegrees/180)*sym(pi);%%calculating angle in
radian%%
(code ends above)
save above file as rad.m in matlab.
Min & Max are the minimum and maximum value of angle in degrees.
Now in command window type 'rad(a,b)' and click run where a & b should be a real number.
Let us take an example let a=30,b=360.You will get following output: