你好同学,代码供参考:
A = eval(input('input A:','s'));
b = eval(input('input b:','s'));
detA = det(A);
fprintf('the determinant of A is %f\n',detA);
if(detA~=0)
invA = inv(A);
[m,n] = size(A);
[p,q] = size(b);
if(n==p)
v=invA*b;
fprintf('V1=%f, V2=%f, V3=%f\n', v);
else
disp('inner dimensions must be equal')
end
end
示例输入输出
input A:[1,0,2; -6,10,-3;0,-1,5]
input b:[6;2;3]
the determinant of A is 59.000000
V1=3.694915, V2=2.762712, V3=1.152542
如有帮助还望题主给个宝贵的采纳支持一下答主答题呢,谢谢啦(づ ̄3 ̄)づ╭❤~