How to correctly present results of linear equation with f print f function?
조회 수: 2 (최근 30일)
이전 댓글 표시
% A
syms x1 x2 x3 % Defining the vairables
eqns = [x1 - 2*x2 + x3 == 0, % First equation
2*x2 - 8*x3 == 8, % Second equation
-4*x1 + 5*x2 + 9*x3 == -9]; % Third equation
[A] = equationsToMatrix(eqns) % Forming the coefficient matrix
% B
syms x1 x2 x3
eqns = [x1 - 2*x2 + x3 == 0,
2*x2 - 8*x3 == 8,
-4*x1 + 5*x2 + 9*x3 == -9];
[A,b] = equationsToMatrix(eqns) % Forming the augumented matrix
% C
A = [1 -2 1;
0 2 -8;
-4 5 9]
b = [0; 8; -9]
[L, U, P] = lu(A) % L = all multipliers, U = upper triangular matrix, P = row interchanges
y = L\(P*b) % Forward substitution
x = U\y % Backward substitution
How can I present the result (x) correctly with the fprintf function?
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!