(volumeSphere.m). What you have to do is ceate 3 files and apprpriate codes (given below ) to respective files.
THIS CODE IS PERFECTLY RUNNING. OUTPUT IS ALSO GIVEN. PLease put propercode in proper file
ANY OTHER SUGGESTION IS WELCOME
——————————————————————————————————————————-
%YOUR CODE STARTS FROM HERE
% Main script file mainscript.m
%COPY FOLLOWING Coodes (upto END OF MAINSCRIPT) into mainscript.m file
% ———————————————————–
clc;
global r
r=5;
cube=@(x) x.^3;
%% row matrix
rowMat=[1,2,3,4]
% Column matrix
colMat=[1;2;3;4]
% Cube of row matrix
cubeofRowMat=cube(rowMat)
%Cube of row matrix
cubeofColMat=cube(colMat)
%% Call to compute area of circle
AreaofCircle=areaCircle()
%% Call to compute volume of shpere
VolumeofSphere=volumeSphere()
%—– END OF MAINSCRIPT———————————————–
% Create a function file areaCircle.m and Copy Following codes (UPTO END OF area_cilcle ) into this file
% Function File name : areaCircle.m
%————————————————————–
function A = areaCircle()
%areaCircle return the area
% of a circle with given global radius r
global r;
A=pi*r*r;
end
%——————– END OF areaCircle ————————————–
% Create a function file volumeSphere.m and Copy Following codes (UPTO END OF volumeSphere ) into this file
% Function File name : volumeSphere.m
%————————————————————–
function V =volumeSphere()
%volumeSphere return the volume
% of a sphere with given global radius r
global r;
V=pi*r*r*r*4/3;
end
% ———–END OF volumeSphere ———————————————-
%output below
