Symbolic Integral Giving answer as infinity
Afficher commentaires plus anciens
Hi,
I am writing a function and need some help. I want to solve a symbolic integral, but it keeps outputting the answer as infinity. The integral is a function of x.
syms Es Ib Ic H L P x R2 R1
Vin5=@(x) (1/(E*Ic))
int(Vin5,0,H)
Réponses (1)
Star Strider
le 27 Oct 2019
Note that the RHS of ‘Vin5’ is not a function of ‘x’. You have also not defined ‘E’.
The correct symbolic expression is:
syms Es Ib Ic H L P x R2 R1
Vin5(x) = (1/(E*Ic))
int(Vin5,0,H)
however ‘E’ remains undefined, and will throw an error.
If you instead use:
Vin5(x) = (1/(Es*Ic))
the integral is:
H/(Es*Ic)
That still does not solve the problem of ‘Vin5’ having no expressions in terms of ‘x’ on the RHS. However it will produce an appropriate result, if you are integrating a constant.
6 commentaires
Socheat Tun
le 27 Oct 2019
Star Strider
le 27 Oct 2019
Please post the complete code you used.
Walter Roberson
le 27 Oct 2019
Check if you accidentally assigned to a variable named int
Socheat Tun
le 28 Oct 2019
If you implement the actual suggestion, you should not receive an error.
clear
clc
syms E a H G L P R2 R1 x
Ib=(2*a*L)/E;
Ic=(a*H)/E;
%Integration of virtual work equations for released structure
% Vin1=@(x) (P/(4*E*Ic))*(-H+x); % Don't do this.
Vin1(x) = (P/(4*E*Ic))*(-H+x);
dhreleased=int(Vin1,0,H)
% Vin2=@(x) (P*L/4)*(-1/(E*Ic)) % Don't do this.
Vin2(x) = (P*L/4)*(-1/(E*Ic));
thetareleased=int(Vin2,0,H)
Star Strider
le 28 Oct 2019
I just now saw this.
I agree with Daniel M.
It is best to use symbolic functions — not anonymous functions — with symbolic operations (such as int).
Your (slightly edited) code, replacing the anonymous functions with symbolic functions:
syms E a H G L P R2 R1 x
Ib=(2*a*L)/E;
Ic=(a*H)/E;
%Integration of virtual work equations for released structure
Vin1(x) = (P/(4*E*Ic))*(-H+x);
dhreleased=int(Vin1,0,H)
Vin2(x) = (P*L/4)*(-1/(E*Ic))
thetareleased=int(Vin2,0,H)
with the functions defined as:
Vin1(x) =
-(P*(H - x))/(4*H*a)
Vin2(x) =
-(L*P)/(4*H*a)
and the integrations produce these results when I run your code:
dhreleased =
-(H*P)/(8*a)
thetareleased =
-(L*P)/(4*a)
Note that ‘Vin2’ is a constant, and not a funciton of ‘x’.
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!