Integrals with syms over the variable x

1 次查看(过去 30 天)
Hi!
I want to solve the following integrals but i want it to integrate over the variable x while c1, c2 and c3 are constants that are not known beforehand but the plan is to get my 3 equations so i can solve the equationsystem after the integrations for c1,c2 and c3. Can someone help me, please? The code i got so far is the one below.
My 3 equations:
% Galerkin method
A0=6e-4;
E=70e9;
L=0.5;
P=5000;
syms c1 c2 c3
e1=E*A0*x * (c1*(2 - (x/L)) + c2*(4*x - 2* (x^2) *(1/L)) + c3*(6*(x^2) - 3*(x^3)*(1/L)) - P)
e2=E*A0*x^2 * (c1*(2 - (x/L)) + c2*(4*x - 2* (x^2) *(1/L)) + c3*(6*(x^2) - 3*(x^3)*(1/L)) - P)
e3=E*A0*x^3 * (c1*(2 - (x/L)) + c2*(4*x - 2* (x^2) *(1/L)) + c3*(6*(x^2) - 3*(x^3)*(1/L)) - P)
F1=int(e1, L ,0);
F2=int(e2, L, 0);
F3=int(e3, L, 0);
  4 个评论
Bjorn Gustavsson
Bjorn Gustavsson 2021-1-24
Good!
Walter's advice to explicitly state the variable of integration is good. Matlab use a reasonably clever procedure to decide that, but if one are explicit about it things will not go wrong.
Daniel Arvidsson
Daniel Arvidsson 2021-1-24
Yes, very true, thanks for input Björn! :)

请先登录,再进行评论。

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2021-1-22
If you have the symbolic toolbox this can be done:
syms E A0 L P c1 c2 c3 P x
e1=E*A0*x * (c1*(2 - (x/L)) + c2*(4*x - 2* (x^2) *(1/L)) + c3*(6*(x^2) - 3*(x^3)*(1/L)) - P);
F1=int(e1, L ,0)
% Returns:
% F1 =
%
% -(A0*E*L^2*(27*c3*L^2 + 25*c2*L - 15*P + 20*c1))/30
The symbolic toolbox should also be able to solve the 3 eqs for c1, c2, and c3.
But considering that you have 3 polynomials in x, you should be able to calculate the integrals by hand easily.
HTH
  2 个评论
Walter Roberson
Walter Roberson 2021-1-22
I recommend specifying the variable of integration explicitly, as there are four variables in e1 and it is clearer to specify the variable of integration instead of requiring that the person reading the code be completely certain about the procedure for chosing the default variable.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by