第一题 matlab 代码 面积结果存放在变量 area 中
clear all
x= linspace(-10,10,1000);
y1=x.^2/8;
y2=64./(x.^2+16);
plot(x,y1)
hold on
plot(x,y2)
xlabel('x')
ylabel('y')
title('Question 1')
legend('y1=x^2/8','y2=64/(x^2+16)')
%% calculate area
syms x y
f1=x^2/8-y;
f2=64/(x^2+16)-y;
cro=solve(f1,f2); % calculate intersection points
cro_re=[cro.x(3:4) cro.y(3:4)]; % select real results
f3=x^2/8;
f4=64/(x^2+16);
area=abs(int(f3,cro_re(1,1),cro_re(2,1))-int(f4,cro_re(1,1),cro_re(2,1))); % result
第二题马上跟进