Mathematics Using Matlab

Green’s theorem, Surf & Fsurf, Triplequad and Integral13

This is a sample Matlab assignment solution that involves the use of Surf & Fsurf Matlab function and Triplequad and Integral13 Matlab command. The expert has showcased the application of Green’s theorem. S(he) has computed the right and left side of Green’s theorem in two separate problems. In one of the problems movement of a particle is described. Also, the vector expression for force field acting on the particle is given, the expert has calculated the total work done during movement of the particle. In another problem, the equation of a sphere and cone is given. The tutor has shown, how to use “surf” & “fsurf” function to plot the ice cream cone cut out of the sphere. The same ice cream cone has been plotted by adding normal vectors. In the last part of the assignment, moments of a solid D are given about the coordinate axes, expert has calculated moments of inertia about the Z-axis of the same ice cream cone using “triplequad” & “integral13” matlab command.

SOLUTION : –

clear all

clc

Fxy=@(x,y)x+y ;

xmin=1;

xmax=5;

ymin=6;

ymax=@(x) 6+sqrt((2-0.5*(x-3).^2));

I1 = integral2(Fxy,xmin,xmax,ymin,ymax)

xi=xmin:0.1:xmax;

yi=ymax(xi);

scatter(xi,yi)

F2yx=@(y,x) x+y;

ymin=2;

ymax=6;

xmin=@(y) 4-y/2;

xmax=@(y) 2+y/2;

I2 = integral2(F2yx,ymin,ymax,xmin,xmax)

I=I1+I2;

fprintf(‘the required value is:[%d]\n’,I)

hold on

yj=2:0.1:6;

xj=xmin(yj);

scatter(xj,yj);

xj=xmax(yj);

hold on

scatter(xj,yj)

clear all

clc

a=2;

b=sqrt(2);

f = @(t) 0.5*(6+b*sin(t)).^2*a.*sin(t) + 0.5*(3+a*sin(t)).^2*b.*cos(t);

I1 = integral(f,0,pi/2)

f2 = @(t) (2+4*t).^2 + 2*(3-2*t).^2 ;

I2 = integral(f2,0,1)

f3 = @(t) -(2+4*t).^2 + (3+2*t).^2*2;

I3 = integral(f3,0,1)

I = I1+I2+I3;

fprintf(‘the first integral is:[%d]\n’,I1)

fprintf(‘the second integral is:[%d]\n’,I2)

fprintf(‘the third integral is:[%d]\n’,I3)

fprintf(‘the total integral is:[%d]\n’,I)

clear all

clc

% Path 1

Ft=@(t) 3*sin(9*t.^2);

I1t=integral(Ft,0,1)

% Path 2

Gt=@(t) 5*log(4+15*t);

I2t=integral(Gt,0,1)

Ht=@(t) -3*(sin((3-3*t).^2+(5-5*t).^2)) -5 * log(4+(3-3*t).*(5-5*t));

I3t=integral(Ht,0,1)

I = I1t+I2t+I3t;

fprintf(‘the work done is:[%d]\n’,I)

clear,clc

r=[0:0.2:2];

theta=[0:pi/50:2*pi];

[R,THETA]=meshgrid(r,theta);

X=R.*cos(THETA);

Y=R.*sin(THETA);

Z=3.5*R;

surf(X+8,Y+2,Z)

hold on

%surfnorm(X+8,Y+2,Z)

phi=[0:pi/50:pi];

theta=[0:pi/35:2*pi];

[THETA,PHI]=meshgrid(theta,phi);

radius=2;

X=radius*sin(PHI).*cos(THETA);

Y=radius*sin(PHI).*sin(THETA);

Z=radius*cos(PHI);

surf(X(1:26,:)+8,Y(1:26,:)+2,Z(1:26,:)+7)

xlabel(‘x’)

ylabel(‘y’)

zlabel(‘z’)

print(‘cone’,’-dpng’)

clear,clc

r=[0:0.2:2];

theta=[0:pi/50:2*pi];

[R,THETA]=meshgrid(r,theta)

X=R.*cos(THETA);

Y=R.*sin(THETA);

Z=3.5*R;

surf(X+8,Y+2,Z)

hold on

%surfnorm(X+8,Y+2,Z)

[U,V,W] = surfnorm(X+8,Y+2,Z);

quiver3(X+8,Y+2,Z,-U,-V,W,0.5);

hold on

phi=[0:pi/50:pi];

theta=[0:pi/35:2*pi];

[THETA,PHI]=meshgrid(theta,phi);

radius=2;

X=radius*sin(PHI).*cos(THETA);

Y=radius*sin(PHI).*sin(THETA);

Z=radius*cos(PHI);

surf(X(1:26,:)+8,Y(1:26,:)+2,Z(1:26,:)+7)

hold on

[U,V,W] = surfnorm(X(1:26,:)+8,Y(1:26,:)+2,Z(1:26,:)+8);

quiver3(X(1:26,:)+8,Y(1:26,:)+2,Z(1:26,:)+7,-U,-V,W,0.5);

xlabel(‘x’)

ylabel(‘y’)

zlabel(‘z’)

print(‘coneWithNormal’,’-dpng’)

clear all

clc

R=2;

fun=@ (r,theta) r.^3.*(7-7/2*r);

Qcone = integral2(fun,0,R,0,2*pi);

fun2=@(r,theta,phi) r.^4.*cos(phi).*sin(phi)

QSphere = integral3(fun2,0,2,0,2*pi,0,pi/2)

Inertia=Qcone+QSphere

fprintf(‘The inertia moment required is:[%d]\n’,Inertia)