Matlab don't show calculated variables.

조회 수: 2 (최근 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 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