Exp-8 Qus:: Finding The Mass of A Three Dimension Alshape and Visualizing The Same Using Matlab

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Exp-8

Qus:
Finding the mass of a three dimension alshape and visualizing the
same using MatLab

Ans:
MatLab Code for determining volume and drawing the solid
region:

clc
clearvars
close all
syms x y z
zlim = input('Enter the z−limits as [z0 z1]: '); % z0 is lower- and z1 is upper-surface
ylim = input('Enter the y−limits as [y0 y1]: '); % y-limits may be function or constant
xlim = input('Enter the x−limits as [x0 x1]: '); % x-limits may be constant or function
if isa(ylim, 'sym')
vol = int(int(int(1,z,zlim(1),zlim(2)),y,ylim(1),ylim(2)),x,xlim(1),xlim(2));
viewSolid(z,zlim(1)+0 x y,zlim(2)+0 x y,y,ylim(1)+0 x,ylim(2)+0 x,x,xlim(1),xlim(2));
else
vol = int(int(int(1,z,zlim(1),zlim(2)),x,xlim(1),xlim(2)),y,ylim(1),ylim(2));
viewSolidone(z,zlim(1)+0 x y,zlim(2)+0 x y,x,xlim(1)+0 y,xlim(2)+0 y,y,ylim(1),ylim(2));
end
disp(['The volume of the solid is: ', char(vol)]);

Example. Find the volume of the solid given by z= (1−x2−y2)i.e. the upper hemisphere of the unit
Sphere centere dat origin.
Example. Setup a triple integral for the volume of solid region bounded below by the paraboloidz=x2+y2
And above the sphere x2+y2+z2=6.

MatLab Code for calculating mass and kinetic energy:

clc
clearvars
close all
syms x y z
v = input('Enter the velocity at the time of impact: ');
rho = input('Enter the density at the point (x,y,z): ');
zlim = input('Enter the z−limits as [z0 z1]: '); % z0 is lower- and z1 is upper-surface
ylim = input('Enter the y−limits as [y0 y1]: '); % y-limits may be function or constant
xlim = input('Enter the x−limits as [x0 x1]: '); % x-limits may be constant or function
if isa(ylim, 'sym')
mass = int(int(int(rho,z,zlim(1),zlim(2)),y,ylim(1),ylim(2)),x,xlim(1),xlim(2));
else
mass = int(int(int(rho,z,zlim(1),zlim(2)),x,xlim(1),xlim(2)),y,ylim(1),ylim(2));
end
disp(['The mass of the object is: ', num2str(double(mass)), ' kg.']);
KE = double(0.5 mass v^2);
rict = double((log10(KE)+2.22)/2.57);
disp(['The kinetic energy released in the impact is ', num2str(KE),' Joules and is
equivalent to an earthquake of magnitude: ' num2str(rict)])

Example. Find the energy dissipated in the collision of an spherical asteroid of radius 1 km and
density
3500kg/m3,iftheimpactvelocitywas30km/sec.
Enter the velocity at the time of impact: 30000
Enter the density at the point (x,y,z): 3500
Enter the z−limits as [z0 z1]: [−sqrt(1000^2−x^2−y^2) sqrt(1000^2−x^2−y^2)]
Enter the y−limits as [y0 y1]: [−sqrt(1000^2−x^2) sqrt(1000^2−x^2)]
Enter the x−limits as [x0 x1]: [−1000 1000]
The mass of the object is: 14660765716752.37 kg.
The kinetic energy released in the impact is 6.597344572538565e+21 Joules and is
equivalent to an earthquake of magnitude: 9.3538

You might also like