Integrals with syms over the variable x

1 Ansicht (letzte 30 Tage)
Daniel Arvidsson
Daniel Arvidsson am 22 Jan. 2021
Kommentiert: Daniel Arvidsson am 24 Jan. 2021
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 Kommentare
Bjorn Gustavsson
Bjorn Gustavsson am 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 am 24 Jan. 2021
Yes, very true, thanks for input Björn! :)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Bjorn Gustavsson
Bjorn Gustavsson am 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 Kommentare
Walter Roberson
Walter Roberson am 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 am 24 Jan. 2021
Very true, Walter, thanks for input :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by