Passing integral to another integral
1 view (last 30 days)
Show older comments
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."
0 Comments
Answers (1)
Gautham Sholingar
on 16 May 2017
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:
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!