question about result in matlab

1 次查看(过去 30 天)
% SOLVE EXAM
% A=U23 , B=U33 , C=U43 , D=U22 , E=U32 , F=U42
syms A B C D E F
eqn1= A - 0.25*E == 6.25;
eqn2=B-0.25*F-0.25*D == 4.45;
eqn3=C-0.25*E == 6.8;
eqn4=D-0.25*B==5.5;
eqn5=E-0.25*C-0.25*A==3.87;
eqn6=F-0.25*B==6.45;
[X,Y]=equationsToMatrix([eqn1,eqn2,eqn3,eqn4,eqn5,eqn6]);
n=linsolve(X,Y);
display(n)
why result appear :
11603/1400
17/2
12373/1400
61/8
2853/350
343/40

采纳的回答

Sudharsana Iyengar
Sudharsana Iyengar 2021-11-16
Try this
syms A B C D E F
eqn1= A - 0.25*E == 6.25;
eqn2=B-0.25*F-0.25*D == 4.45;
eqn3=C-0.25*E == 6.8;
eqn4=D-0.25*B==5.5;
eqn5=E-0.25*C-0.25*A==3.87;
eqn6=F-0.25*B==6.45;
[X,Y]=equationsToMatrix([eqn1,eqn2,eqn3,eqn4,eqn5,eqn6]);
%n=linsolve(X,Y);
n = double(linsolve(X,Y)); %makes everything in float format
display(n)
n = 6×1
8.2879 8.5000 8.8379 7.6250 8.1514 8.5750
n = vpa(linsolve(X,Y));
display(n)
n = 

更多回答(1 个)

KSSV
KSSV 2021-11-16
编辑:KSSV 2021-11-16
Becuase n is a class of sym. Use double.
double(n)
Also note that you need not use syms to achieve this. Frame your matrices and use \.
n = double(X)\double(Y)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by