Develop an M-file to determine polar coordinates as described in Prob. 3.6. However, rather than designing the

Question:

Develop an M-file to determine polar coordinates as described in Prob. 3.6. However, rather than designing the function to evaluate a single case, pass vectors of x and y. Have the function display the results as a table with columns for x, y, r, and . Test the program for the cases outlined in Prob. 3.6.


Data From Problem 3.6

Two distances are required to specify the location of a  point relative to an origin in two-dimensional space  (Fig. P3.6):
• The horizontal and vertical distances (x, y) in Cartesian  coordinates.
• The radius and angle (r, θ) in polar coordinates.
It is relatively straightforward to compute Cartesian coordinates  (x, y) on the basis of polar coordinates (r, θ). The  reverse process is not so simple. The radius can be computed  by the following formula:

If the coordinates lie within the first and fourth coordinates (i.e., x > 0), then a simple formula can be used to compute θ:

The difficulty arises for the other cases. The following table summarizes the possibilities:

Write a well-structured M-file using if...else if structures to calculate r and θ as a function of x and y. Express the final results for θ in degrees. Test your program by evaluating the following cases:

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: