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

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:

r = x + y

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:

r = x + y

Step by Step Solution

3.32 Rating (176 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve Prob 36 we need to write an Mfile a MATLAB script that converts Cartesian coordinates x y t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Applied Numerical Methods Questions!