Matlab solution for DR and RD. Urgent help !

Hi i need to write Matlab solution for the function DR that ask for angle in degrees and computes the equivalent radians, and another function RD that ask for angle in radians compute the equivalent degrees. And my function should be able to accept both scalar and matrix input.
The script should keep running until no number is provided to convert.
[The function[b] isempty[/b] will be useful here]

This what i write on Matlab

degrees = radians * 180/pi
radians = degrees * pi/180

function output = DR(x)
%This function changes degrees to radians
output = x*pi/180;

function output = RD(x)
%This function changes radians to degrees
output = x*180/pi;

selection = input ('Enter 1 for Degrees to Radians or Enter 2 for Radians to Degrees')
output = input (' Enter the number for calculation ' )

if selection = 1 then
output = DR(x)
if selection = 2 then
output = RD(x)

It can't work at all !! Can someone please help me?


  • You have to change this line:
    [code]output = input (' Enter the number for calculation ' )[/code]
    with this:
    [code]x = input (' Enter the number for calculation ' )[/code]

    and, at the end of the code:
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion