Matlab don't show calculated variables.

1 visualización (últimos 30 días)
Tiago Araujo
Tiago Araujo el 13 de Abr. de 2021
Editada: Walter Roberson el 14 de Abr. de 2021
I wrote this:
syms C0 C1 C2 C3 X L P EI1 EI2
Y(X)=C0+C1*X+C2*X^2+C3*X^3;
dY(X)=diff(Y(X),X);
d2Y(X)=diff(dY(X),X);
f0 = Y(0) == 0;
f1 = Y(L) == 0;
R=solve([f0,f1],[C0,C1]);
C0 = R.C0;
C1 = R.C1;
U=(EI1/2)*int(d2Y(X)^2,[0 L/2])+(EI2/2)*int(d2Y(X)^2,[L/2 L]);
V=-P*Y(L/2);
PI(C2,C3)=U+V;
dPIdC2=diff(PI(C2,C3),C2);
dPIdC3=diff(PI(C2,C3),C3);
f2 = dPIdC2 == 0;
f3 = dPIdC3 == 0;
S=solve([f2,f3],[C2,C3]);
C2 = S.C2;
C3 = S.C3;
C= ([C0;C1;C2;C3]);
disp(C);
Y(X)=C0+C1*X+C2*X^2+C3*X^3;
disp Y(X);
disp (Y(X));
FLECHA = Y(L/2)
But Matlab returns:
C =
0
- C3*L^2 - C2*L
(P*(EI1*L + 11*EI2*L))/(4*(EI1^2 + 14*EI1*EI2 + EI2^2))
-(P*(EI1 + 7*EI2))/(6*(EI1^2 + 14*EI1*EI2 + EI2^2))
______________________________________________
Y(X)
C3*X^3 + C2*X^2 + C1*X + C0
FLECHA
(C3*L^3)/8 + (C2*L^2)/4 + (C1*L)/2 + C0
It dont show Y(X) in terms of calculated values of C0, C1, C2 and C3.
I Want the Y(x) in function of P, L, EI1, EI2, (...), with this script these variables C0, C1... are calculateds but MATLAB dont write Y(X) em terms of them.

Respuesta aceptada

Tiago Araujo
Tiago Araujo el 14 de Abr. de 2021
Editada: Walter Roberson el 14 de Abr. de 2021
I fixed doing:
syms C0 C1 C2 C3 X L P EI1 EI2
Y(X)=C0+C1*X+C2*X^2+C3*X^3;
dY(X)=diff(Y(X),X);
d2Y(X)=diff(dY(X),X);
f0 = Y(0) == 0;
f1 = Y(L) == 0;
U=(EI1/2)*int(d2Y(X)^2,[0 L/2])+(EI2/2)*int(d2Y(X)^2,[L/2 L]);
V=-P*Y(L/2);
PI(C2,C3)=U+V;
dPIdC2=diff(PI(C2,C3),C2);
dPIdC3=diff(PI(C2,C3),C3);
f2 = dPIdC2 == 0;
f3 = dPIdC3 == 0;
S=solve([f0,f1,f2,f3],[C0,C1,C2,C3]);
C0=S.C0;
C1=S.C1;
C2 = S.C2;
C3 = S.C3;
C= ([C0;C1;C2;C3]);
disp(C);
Y(X)=C0+C1*X+C2*X^2+C3*X^3;
disp Y(X);
disp (Y(X));
FLECHA = Y(L/2)

Más respuestas (1)

Jan
Jan el 14 de Abr. de 2021
I get a dfifferent output than you:
syms C0 C1 C2 C3 X L P EI1 EI2
Y(X)=C0+C1*X+C2*X^2+C3*X^3;
dY(X)=diff(Y(X),X);
d2Y(X)=diff(dY(X),X);
f0 = Y(0) == 0;
f1 = Y(L) == 0;
R=solve([f0,f1],[C0,C1]);
C0 = R.C0;
C1 = R.C1;
U=(EI1/2)*int(d2Y(X)^2,[0 L/2])+(EI2/2)*int(d2Y(X)^2,[L/2 L]);
V=-P*Y(L/2);
PI(C2,C3)=U+V;
dPIdC2=diff(PI(C2,C3),C2);
dPIdC3=diff(PI(C2,C3),C3);
f2 = dPIdC2 == 0;
f3 = dPIdC3 == 0;
S=solve([f2,f3],[C2,C3]);
C2 = S.C2;
C3 = S.C3;
C= ([C0;C1;C2;C3]);
disp(C);
Y(X)=C0+C1*X+C2*X^2+C3*X^3;
disp Y(X);
Y(X)
disp (Y(X));
FLECHA = Y(L/2)
FLECHA = 
  1 comentario
Tiago Araujo
Tiago Araujo el 14 de Abr. de 2021
Hi! Thanks!
But, have you seen that the C3 and C2 are still present in the Y(X) instead of their value in function of EI, P and L... ?
I need Y(X) only in function of EI1 EI2 P and L...

Iniciar sesión para comentar.

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