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