Matlab don't show calculated variables.

1 回表示 (過去 30 日間)
Tiago Araujo
Tiago Araujo 2021 年 4 月 13 日
編集済み: Walter Roberson 2021 年 4 月 14 日
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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by