converting degrees and radian

19 ビュー (過去 30 日間)
Vin diz
Vin diz 2021 年 2 月 2 日
回答済み: Daniel Pollard 2021 年 2 月 2 日
how do a make a solution tht prompts user to input (A or B) . A being degree to radian. B being radian to degree. others input error. if prompted A ..it will ask for angle in degree and displays in equivalent radians. if prompted B will ask for a radian and displays in degrees.Should be able to accept both scalar and matrix input/
degrees=radians*180/pi
radian=degrees*pi/180
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 2 日
menu().

サインインしてコメントする。

回答 (1 件)

Daniel Pollard
Daniel Pollard 2021 年 2 月 2 日
Something like
option = input("Type A for degree to radians, and B for radians to degrees: ", 's')
if option == "A"
degs = input("Please insert a value in degrees: ")
rads = degs*pi/180;
disp(degs+" degrees = "+rads+" radians")
elseif option == "B"
rads = input("Please insert a value in radians: ")
degs = rads*180/pi;
disp(rads+" radians = "+degs+" degrees")
else
error("Please insert only A or B")
end
should do what you want.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by