question about result in matlab

1 visualizzazione (ultimi 30 giorni)
% 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

Risposta accettata

Sudharsana Iyengar
Sudharsana Iyengar il 16 Nov 2021
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 = 

Più risposte (1)

KSSV
KSSV il 16 Nov 2021
Modificato: KSSV il 16 Nov 2021
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)

Community Treasure Hunt

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

Start Hunting!

Translated by