Matlab don't show calculated variables.

1 次查看(过去 30 天)
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.

采纳的回答

Tiago Araujo
Tiago Araujo 2021-4-14
编辑:Walter Roberson 2021-4-14
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)

更多回答(1 个)

Jan
Jan 2021-4-14
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 个评论
Tiago Araujo
Tiago Araujo 2021-4-14
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...

请先登录,再进行评论。

类别

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