Integrals with syms over the variable x

1 visualización (últimos 30 días)
Daniel Arvidsson
Daniel Arvidsson el 22 de En. de 2021
Comentada: Daniel Arvidsson el 24 de En. de 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 comentarios
Bjorn Gustavsson
Bjorn Gustavsson el 24 de En. de 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 el 24 de En. de 2021
Yes, very true, thanks for input Björn! :)

Iniciar sesión para comentar.

Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 22 de En. de 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 comentarios
Walter Roberson
Walter Roberson el 22 de En. de 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 el 24 de En. de 2021
Very true, Walter, thanks for input :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by