필터 지우기
필터 지우기

Determine the area between f(x) and the x axis on the interval [-1,8] by using the zeros.

조회 수: 2 (최근 30일)
Hi there
I need to determine the area between f(x) and the x axis on the interval [-1,8] by using the zeros.
f(x) = 2*x.^3 -15.4*x.^2 +2.7*x +2.25
I have gotten the zeros as -0.3 : 0.5 : 7.5 ...
Please note that this is not determining the area under f(x) NOR is it the definite intergral of f(x).

답변 (1개)

Image Analyst
Image Analyst 2020년 12월 6일
편집: Image Analyst 2020년 12월 6일
Try this:
numElements = 50000;
x = linspace(-1, 8, numElements);
fx = 2*x.^3 - 15.4*x.^2 + 2.7*x + 2.25;
plot(x, fx, 'b-', 'LineWidth', 2);
grid on;
yline(0, 'LineWidth', 2); % Draw x axis.
xlabel('x', 'FontSize', 20);
ylabel('f(x)', 'FontSize', 20);
aboveZero = fx >= 0;
deltaX = x(2) - x(1)
areaAboveZero = sum(fx(aboveZero)) * deltaX
You get
deltaX =
0.000180003600071976
areaAboveZero =
16.1831197098485
If you need it more accurately than that you can either increase the number of points or use trapz(), but I think for most purposes, this should be accurate enough.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by