Question: HW 6 In 3 D space, the Cartesian coordinates ( x , y , z ) can be converted to spherical coordinates ( radius r

HW 6
In 3D space, the Cartesian coordinates (x,y,z) can be converted to spherical coordinates (radius r, polar angle, , azimuth angle, ) by the following equations:
r=x2+y2+z22,=cos-1(zr),=tan-1(yx)
Write a function fn_printspherical that prints the Cartesian coordinates (x,y,z) and corresponding spherical coordinates, (r,,). The function fn_ printspherical calls a subfunction fn_convert2spher that converts from Cartesian to spherical coordinates.
Write a script, CartSpher that reads the Cartesian coordinates from an external file, convert to spherical coordinate, and print the results. When the script reads the Cartesian coordinates from a file, assume that x,y,z are saved in matrix, thus fn_printspherical should be in the loop to print all the results.
Here is the requirement for the script:
xYZ.txt
\table[[8.1,1.6,6.6],[9.1,9.7,0.4],[1.3,9.6,8.5],[9.1,4.9,9.3],[6.3,8,6.8],[1,1.4,7.6],[2.8,4.2,7.4],[5.5,9.2,3.9],[9.6,7.9,6.6],[9.6,9.6,1.7]]
Read the file (XYZ.txt) by using the following function
-input (Let user input file name)
-load (read the file that user input)
When you load the data, assign the data values to the matrix variable. Use this matrix variable as input variable(s) to the function, fn_printspherical
Display should follow the below format
 HW 6 In 3D space, the Cartesian coordinates (x,y,z) can be

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!