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
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