Professional Documents
Culture Documents
01:8;
y=fun(x)
y = 1×801
4.0000 3.9791 3.9582 3.9375 3.9170 3.8965 3.8761 3.8559
figure(1)
plot(x,y,"Linewidth",2)
axis([0 10 0 4])
xlabel('x variable')
ylabel('y variable')
Q = quad(@fun,0,8);
Q
Q = 16.0000
1
0.1 to 1 (the smaller the better, but
sum=0;
for x=0:dx:8
sum=sum+fun(x)*dx; % 조건반복으로 0에서 8까지 정해준 dx 범위로 곱해나간다.
end
disp('')
disp('The computed integrals of the function y(x) between');
x = 0 and x = 8 are
quad integral =
16.000000
custom summation integral = 16.200000
figure(2)
for x=0:dx:8
patch([x-dx/2; x-dx/2; x+dx/2; x+dx/2], ...
[0; fun(x); fun(x); 0], [0.5 0.5 0.5])
end
2
custom summation to compute the integral quadrature integral - Task4
hold on
x=0:0.01:8;
y=fun(x);
h=plot(x,y,'LineWidth', 2)
h =
Line - 속성 있음:
모든 속성 표시
axis([0 10 0 4])
xlabel('x variable') % axes labels
ylabel('y variable') % axes labels
3
4