Passing integral to another integral

1 次查看(过去 30 天)
By no means am I a MATLAB expert. I'm trying to pass an integral to another integral, in an instance where there's no obvious way to write this as higher-dimensional integral. For instance, suppose I need to integrate the square of a finite integral:
f = @(x) sin(x).^2
g = @(x) integral(@(z)f(z),0,x)
h = @(x) integral(@(z)g(z).^2,0,x)
The problem I run into is that, to compute h, the limits of g are not scalars. The error message is: "A and B must be floating-point scalars."

回答(1 个)

Gautham Sholingar
Gautham Sholingar 2017-5-16
A possible approach for this scenario is to use the functions available in the Symbolic toolbox to declare variables x,y,z and three functions which you can call with the specific integral limits. For example:
syms x y z % declare symbols
F = sin(x).^2;
G = int(F,x,0,y);
H = int(G^2,y,0,z);
subs(H,z,2)
The following documentation links explain these function in detail:

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by