Matlab Assignment 3
Matlab Assignment 3
Name: - Gineeth.R
MATLAB CODE :
clc
clear all
syms x
n = input('Number of intervals:');
value = 0;
dx = (b-a)/n;
for k=1:n
c = a+k*dx;
d = subs(f,x,c);
value = value + d;
end
value = dx*value
figure(1)
ezplot(f,[a,b])
z = int(f,a,b)
figure(2)
rsums(f,a,b)
Ans)
(x^3*cos(x/2)+1/2).*(sqrt(4-x^2))
-2
Number of intervals:
10
value =
z=
MATLAB CODE :
clc
clear all
syms x y real
fg = figure;
ax = axes;
t = solve(y1-y2);
k = double(t)
n = length(k)
m1 = min(k)
m2 = max(k)
ez1 = ezplot(y1,[m1-1,m2+1]);
hold on
TA = 0
ez2 = ezplot(y2,[m1-1,m2+1]);
if n>2
for i=1:n-1
A = int(y1-y2,t(i),t(i+1))
TA = TA + abs(A)
x1 = linspace(k(i),k(i+1));
yy1 = subs(y1,x,x1);
yy2 = subs(y2,x,x1);
x1 = [x1,fliplr(x1)];
yy = [yy1,fliplr(yy2)];
fill(x1,yy,'g')
grid on
end
else
A = int(y1-y2,t(1),t(2))
TA = abs(A)
x1 = linspace(k(1),k(2));
yy1 = subs(y1,x,x1);
yy2 = subs(y2,x,x1);
x1 = [x1,fliplr(x1)];
yy = [yy1,fliplr(yy2)];
fill(x1,yy,'g')
end
Q2) Find the area of the regions enclosed by the curves y = -x^2+4x , y =
x^2-6x+5.
Ans)
-x^2+4*x
x^2-6*x+5
k=
0.5635
4.4365
n=
m1 =
0.5635
m2 =
4.4365
TA =
A=
5*15^(1/2)
TA =
5*15^(1/2)
Q3) Find the area of the regions enclosed by the curves y = 2x^5+3x^4-
5x^3+2x^2-x=1 , y = x^3-2x^2-5x+6.
Ans)
2*x^5+3*x^4-5*x^3+2*x^2-x+1
x^3-2*x^2-5*x+6
k=
0.8443
-0.9099
-2.7258
n=
m1 =
-2.7258
m2 =
0.8443
TA =
A=
TA =
A=
TA =