Integrals with syms over the variable x

1 view (last 30 days)
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 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 24 Jan 2021
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 on 24 Jan 2021
Yes, very true, thanks for input Björn! :)

Sign in to comment.

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 22 Jan 2021
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 Comments
Walter Roberson
Walter Roberson on 22 Jan 2021
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.
Daniel Arvidsson
Daniel Arvidsson on 24 Jan 2021
Very true, Walter, thanks for input :)

Sign in to comment.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox 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!