The following script determines the volume of a trough given f,b and L. f = width = 2, b = x = 0 (as stated in question) and L = length = 5. The script below is what I have written, but it breaks at f2
function vol = viaduct_volume_n9941835(f,b,L)
%Determines the volume of a trough with a cross sectional area defined by
% f(x) = -log(x+0.01)+exp(x). With a horizontal line segment
% g(x) = -log(0.01)+exp(0).
%Introduces functions used
f1 = @(x) -log(x+0.01)+exp(x);
f2 = @(b) -log(b+0.01)+exp(b);
%Determines intercept of two functions
fun = @(x) (-log(x+0.01)+exp(x)) - (-log(0.01)+exp(0));
Intercept = fzero(fun,f)
%Determines definite integrals for f1 and f2
f1_int = integral(f1,0,Intercept);
f2_int = integral(f2,0,Intercept);
%Determines Cross Sectional Area
area = f2_int - f1_int
%Determines Volume of Trough
vol = area * L
end

답변 (1개)

Torsten
Torsten 2017년 8월 7일

0 개 추천

If you want to integrate the constant function f2(x)=-log(b+0.01)+exp(b), just define it this way:
f2=@(x)-log(b+0.01)+exp(b)
Best wishes
Torsten.

카테고리

도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2017년 8월 7일

답변:

2017년 8월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by