Symbolic Integral Giving answer as infinity

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
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
Socheat Tun le 27 Oct 2019
Hey Star Strider,
So I tried typing exactly what you put in and got this error:
Error using sym/subsindex (line 855). It seems that whenever I try to integral 1/(sym), it always inputs an error or inf as the answer. Do you know how to fix this?
Star Strider
Star Strider le 27 Oct 2019
Please post the complete code you used.
Check if you accidentally assigned to a variable named int
Socheat Tun
Socheat Tun le 28 Oct 2019
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)
Output:
Ib =
(2*L*a)/E
Ic =
(H*a)/E
dhreleased =
-(H*P)/(8*a)
Vin2 =
function_handle with value:
@(x)(P*L/4)*(-1/(E*Ic))+0*x
thetareleased =
-Inf*sign(L*P)
Daniel M
Daniel M le 28 Oct 2019
Modifié(e) : Daniel M 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)
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’.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by