question about result in matlab

조회 수: 4 (최근 30일)
oun alsharif
oun alsharif 2021년 11월 16일
댓글: oun alsharif 2021년 11월 16일
% 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에서 Linear Algebra에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by