Calculate the area between two curves
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i need help! i am new at using the Matlab and Scilab softwares and i need to calculate the area between the curves y=f(x) and y=g(x) in the interval [a,b] with a = 3, b = 6,
f (x)=sin(3 x+1) and g(x)=(e∣x∣/2−2−1)
by means of the composite trapezoidal rule with 73 trapezoids,Recall that the area between f and g in [a,b] is
b a ∫ ∣f(x)−g(x)∣dx
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160673/image.png)
The approximate value of the area has to be displayed at the end, and the script must contain all the code to obtain the result.
how do i even begin with this? any help is much appreciated. thanks
0 Kommentare
Akzeptierte Antwort
Alberto
am 11 Apr. 2014
f =@(x) sin(3.*x+1) ;
g=@(x) exp(abs(x)/2 -2)-1;
a=3; b=6;
x=linspace(a,b,73); S=0;
for k=1:length(x)-1
S=S+abs( f(x(k+1)) - g(x(k+1)) - f(x(k)) +g(x(k)) )/2;
end
S
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Robust Control Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!