Question: 2. MATLAB contains a function, sphere, that calculates the 3-D coordinates of a sphere with a specified resolution. The syntax is [x, y, z] =

2. MATLAB contains a function, sphere, that calculates the 3-D coordinates of a sphere with a specified resolution. The syntax is [x, y, z] = sphere(n)

where n is the resolution. The resulting x, y, z coordinates can be used to create a surface plot of the sphere using the surf function.

a. Create a variable n to contain the resolution. Initially set it equal to 10.

b. Generate the coordinates of a sphere using the sphere function.

c. Create a surface plot of the sphere.

d. Set the shading to interp for a smooth plot.

e. The surf function defaults to coloring the plot based on the values of z. By changing the plot to grayscale it gives a shading effect. Change the color map to gray with the function call colormap(gray).

f. The default behavior is to use different lengths for the axes. To make them all the same (so the shape of the sphere isnt distorted), use the daspect function as follows: daspect([1, 1, 1]).

g. Label the x, y, and z axes x, y, and z

h. This plot looks pretty chunky. Create another plot using a resolution of 100 instead of 10

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!