Answered step by step
Verified Expert Solution
Question
1 Approved Answer
HW 6 In 3 D space, the Cartesian coordinates ( x , y , z ) can be converted to spherical coordinates ( radius r
HW
In D space, the Cartesian coordinates can be converted to spherical coordinates radius polar angle, azimuth angle, by the following equations:
Write a function fnprintspherical that prints the Cartesian coordinates and corresponding spherical coordinates, The function printspherical calls a subfunction fnconvertspher 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 are saved in matrix, thus fnprintspherical should be in the loop to print all the results.
Here is the requirement for the script:
table
Read the file XYZtxt 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 variables to the function, fnprintspherical
Display should follow the below format
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started