# question about result in matlab

3 views (last 30 days)
oun alsharif on 16 Nov 2021
Commented: oun alsharif on 16 Nov 2021
% 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 on 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 = oun alsharif on 16 Nov 2021
MANY YHANKS

KSSV on 16 Nov 2021
Edited: KSSV on 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)
oun alsharif on 16 Nov 2021
MANY THANKS