Effacer les filtres
Effacer les filtres

How to use integral when limits are anonymous functions

2 vues (au cours des 30 derniers jours)
Aviral Srivastava
Aviral Srivastava le 25 Avr 2024
Commenté : Walter Roberson le 25 Avr 2024
Greetings
I am evaluating an integral wherein the limits are functions themselves and symbolic variables are involved. I can't use int because it does not yield a complete answer (some of the integrals couldn't be solved symbollically), hence I am using integral with ArrayValued enabled.
My code is something like this:
syms x y(x) f(x,y)
dx = 1e-8;
I = @(x) integral( @y f(x,y), y1(x), y2(x), 'ArrayValued', true)
dI = (I(x=x_0+dx) - I(x))/dx + other leibniz terms as limits are functions of x
When I run this code, I get that A and B ( the limits in the integral function must be floating point scalars)
How do I overcome this?

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Avr 2024
Your problem is unsolvable (in the form stated)
You cannot use integral() with symbolic limits: integral() is strictly a numeric integrator, and cannot handle symbolic limits.
You need to use int(), and just live with the fact that int() is unable to find a solution.
  3 commentaires
Walter Roberson
Walter Roberson le 25 Avr 2024
I = @(x) integral( @y f(x,y), y1(x), y2(x), 'ArrayValued', true)
is not valid syntax. Perhaps you meant
I = @(x) integral( @(y) f(x,y), y1(x), y2(x), 'ArrayValued', true)
Walter Roberson
Walter Roberson le 25 Avr 2024
integral() does not support functions for its limits.
For any one numeric x, you can calculate y1(x), y2(x) and use those constants in integral(). However, you cannot do this for generic symbolic x.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by