Familiarize yourself with the subplot and hold command. Using the subplot and plot commands, plot the volume of a sphere as a function of it’s radius for values of radius from 1 to 10. On the same graph plot the surface area of a sphere as a function of the radius ( from radius = 1 to 10). Use different colors for the two plots ( help plot will give details on how to select colors).
Use the following formulas: Volume of sphere = ( 4/3) * pi * radius^3
Surface area of a sphere = 4 * pi * radius^2
Make use of the built-in MATLAB function called pi which returns the value of pi. The plots for the sphere’s volume and surface area are to be plotted in the left-hand pane of the plot window. Repeat the above two plots, but this time plot the volume of a square and surface area of a square as a function of its length from 1 to 10. These plots are to be graphed in right-hand pane of the plot window.
Volume of a square = length of side^3
Surface area of a square = 6 * length of side^2
Label each axes as appropriate and include titles for the plots.
`Hey,
Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.
clc
clear all
close all
format long
r=1:10;
V=(4/3)*pi*r.^3;
S=4*pi*r.^2;
subplot(1,2,1)
plot(r,V,'-b',r,S,'-g');
xlabel('r');
ylabel('V/S');
title('For sphere');
subplot(1,2,2)
V=r.^3;
S=6*r.^2;
plot(r,V,'-b',r,S,'-g');
xlabel('l');
ylabel('V/S');
title('For cube');
Kindly revert for any queries
Thanks.
Get Answers For Free
Most questions answered within 1 hours.