Write a MATLAB program to prompt the user to enter a value o

Write a MATLAB program to prompt the user to enter a value of x and y corresponding to the (x, y) coordinates of a point in the Cartesian coordinate system. The program should then display one of the following prompts: The point is on the x-axis The point is on the y-axis The point is in the first quadrant The point is in the second quadrant The point is in the third quadrant The point is in the fourth quadrant. Test the program for all 6 cases. Turn in a printout of the program and a printout showing the 6 test cases. Include plenty of comments in your program.

Solution

clear

A = input(\'Enter x-coordinate: \');

B = Input(\'Enter y-coordinate: \');

If A==0

\'The point is on Y-Axis\'
% if the abscissae value is 0, the number lies on the y-axis

                Else

                If B==0
% if the ordinate value is 0, the number lies on the x-axis

                \'The point is on X-axis\'

                                Else

                                If A>0 & B>0
% If both the x-coordinate (abscissae) and y-coordinate(ordinate) both are positive , it lies in the first quadrant as first quadrant encompasses all the +ve x and y-coordinate values.

                                \'The number lies in 1st Quadrant\'

                                                Else

                                                If A<0 & B>0
% If the x-coordinate (abscissae) is negative and y-coordinate(ordinate) is positive , it lies in the second quadrant as second quadrant encompasses all the - ve x and +ve y-coordinate values.

                                                \'The number lies in 2nd Quadrant\'

                                                                Else

                                                                If A<0 & B<0
% If both the x-coordinate (abscissae) and y-coordinate(ordinate) both are negative , it lies in third quadrant as third quadrant encompasses all the –ve x and y-coordinate values.

                                                                \'The number lies in 3rd Quadrant\'

                                                                                Else

                                                                                If A>0 & B<0
% If the x-coordinate (abscissae) is positive and y-coordinate(ordinate) is negative , it lies in the fourth quadrant as fourth quadrant encompasses all the + ve x and -ve y-coordinate values.

                                                                                \'The number lies in 4th Quadrant\'

                                                                                                Else

                                                                                                \'The number is on Origin\'

% if both x and y coordinates have value of 0.

                                                                                End

                                                                End

                                                End

                                End

                End

End

 Write a MATLAB program to prompt the user to enter a value of x and y corresponding to the (x, y) coordinates of a point in the Cartesian coordinate system. Th
 Write a MATLAB program to prompt the user to enter a value of x and y corresponding to the (x, y) coordinates of a point in the Cartesian coordinate system. Th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site