function dientichhinhphang
syms x
f=input('nhap ham f1(x)= ');
g=input('nhap ham f2(x)= ');
disp('nhap doan [a b]')
a=input('a= ');
b=input('b= ');
m=[];
if ~isreal(f-g)
m=solve(char(f-g),x);
i=1;
while i<=length(m)
m=subs(m);
if ~isreal(m(i)) ||m(i)<=a||m(i)>=b
m(i)=[];
i=i-1;
end
i=i+1;
end
m=union(m,m);
end
m=[a;m;b];
S=0;
for i=1:length(m)-1
S=S+abs(int(f-g,x,m(i),m(i+1)));
end
text=['dien tich cua hinh phang bang: ' char(S)];
disp(text)
ezplot(f)
hold on
ezplot(g)
hold off
end
cảm ơn mọi người, giúp em nhé
syms x
f=input('nhap ham f1(x)= ');
g=input('nhap ham f2(x)= ');
disp('nhap doan [a b]')
a=input('a= ');
b=input('b= ');
m=[];
if ~isreal(f-g)
m=solve(char(f-g),x);
i=1;
while i<=length(m)
m=subs(m);
if ~isreal(m(i)) ||m(i)<=a||m(i)>=b
m(i)=[];
i=i-1;
end
i=i+1;
end
m=union(m,m);
end
m=[a;m;b];
S=0;
for i=1:length(m)-1
S=S+abs(int(f-g,x,m(i),m(i+1)));
end
text=['dien tich cua hinh phang bang: ' char(S)];
disp(text)
ezplot(f)
hold on
ezplot(g)
hold off
end
cảm ơn mọi người, giúp em nhé
Comment