Integrating with no variables

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

Answers (1)

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.

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 7 Aug 2017

Answered:

on 7 Aug 2017

Community Treasure Hunt

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

Start Hunting!