Matlab Assignment 4
Matlab Assignment 4
Name :- Gineeth.R
clearvars
syms x ;
Volume = pi*int((f-yr)^2,iL(1),iL(2));
fx = inline(vectorize(f));
xvals = linspace(fL(1),fL(2),201);
xvalsr = fliplr(xvals);
xivals = linspace(iL(1),iL(2),201);
xivalsr = fliplr(xivals);
ylim = fx(xlim);
subplot(2,1,1)
hold on;
plot(xvals,fx(xvals),'-b','Linewidth',2);
set(gca,'XLim',xlim)
xlabel('x-axis');
ylabel('y-axis');
subplot(2,1,2)
hold on;
plot(xivals,fx(xivals),'-b','Linewidth',2);
plot(xivals,-fx(xivals)+2*yr,'-m','Linewidth',2);
set(gca,'XLim',xlim)
xlabel('x-axis');
ylabel('y-axis');
[X,Y,Z] = cylinder(fx(xivals)-yr,100);
Z = iL(1) + Z.*(iL(2)-iL(1));
surf(Z,Y+yr,X,'EdgeColor','none','FaceColor','flat','FaceAlpha',0.6);
hold on;
xlabel('X−axis');
ylabel('Y−axis');
zlabel('Z−axis');
view(22,11);
Q1) Visualize and find the volume of the region in the first quadrant bounded
above by the line y=sqrt(x), below by the curve y=sec(x)tan(x), and on the left by
the y-axis, about the line y=sqrt(2).
Ans)
Graph :-
In Matlab :-
In Command Window :-
Enter the function:
sec(x)*tan(x)
[0 pi/4]
sqrt(2)
[0 pi/4]
Volume is:2.3014
In Figure Window :-
Q2) Visualize and find the volume of the solid generated by revolving region
bounded by curve y=sin(x), 0<=x<= π, about the line y=c, 0<=c<=1 by taking
c=0,0.2,0.4,0.6,0.8,1. Can you identify the range/exact value of c that maximize
and minimize the volume of the solid?
Ans)
Graph :-
C=0 :-
C=0.2 :-
C=0.4 :-
C=0.6 :-
C=0.8 :-
C=1 :-
C=0.7 :-
C=0.65 :-
In Matlab :-
In Command Window :-
i) c=0 :-
sin(x)
[0 pi]
[0 pi]
Volume is:4.9348
In Figure Window :-
In Command Window :-
ii) c=0.2 :-
sin(x)
Enter the interval on which the function is defined:
[0 pi]
0.2
[0 pi]
Volume is:2.8163
In Figure Window :-
In Command Window :-
iii) c=0.4 :-
sin(x)
[0 pi]
0.4
[0 pi]
Volume is:1.4874
In Figure Window :-
In Command Window :-
iv) c=0.6 :-
sin(x)
[0 pi]
0.6
[0 pi]
Volume is:0.94804
In Figure Window :-
In Command Window :-
v) c=0.8 :-
sin(x)
[0 pi]
0.8
[0 pi]
Volume is:1.1983
In Figure Window :-
In Command Window :-
vi) c=1 :-
sin(x)
[0 pi]
Enter the axis of rotation y=c (Enter only c value):
[0 pi]
Volume is:2.238
In Figure Window :-
In Command Window :-
vii) c=0.7 :-
sin(x)
[0 pi]
0.7
[0 pi]
Volume is:0.97445
In Figure Window :-
In Command Window :-
viii) c=0.65 :-
sin(x)
[0 pi]
0.65
Volume is:0.93657
In Figure Window :-
Q3) Modify the above code appropriately to visualize and find the volume of the
solid of revolution by the curve y=tan(πy/4), 0<=y<=1 about the y-axis.
Ans)
Graphs :-
In Matlab :-
In Command Window :-
Enter the function:
4/pi*(atan(x))
[0 1]
[0 1]
Volume is:1.2492
In Figure Window :-
---THE
END---