Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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).

Respuestas (1)

Image Analyst
Image Analyst el 6 de Dic. de 2020
Editada: Image Analyst el 6 de Dic. de 2020
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.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by