Phi*_*hil 1 math matlab linear-algebra
我是MATLAB的新手,我想用它来解决Ax = b系统问题.我在纸上做了这个,知道我想知道它是否正确.问题是它是一个不一致的系统.
A=sym([3/sqrt(29) 3/sqrt(29) -1 0 0 0;
1 -1 0 0 0 0;
4/sqrt(29) 4/sqrt(29) 0 0 0 0;
0 0 1 9/sqrt(101) 0 0;
0 0 0 2/sqrt(101) -1/sqrt(5) 1/sqrt(5);
0 0 0 4/sqrt(101) 2/sqrt(5) 2/sqrt(5)])
c=sym([0 0 -a 0 0 -a])
Run Code Online (Sandbox Code Playgroud)
当我尝试找到解决方案:
A/c
Run Code Online (Sandbox Code Playgroud)
我明白了:
Warning: The system is inconsistent. Solution does not exist.
Run Code Online (Sandbox Code Playgroud)
我在互联网上找到了很多关于这个的主题,但是没有解决方案.这是否意味着MATLAB无法处理它或者是否有办法获得解决方案?
遗憾的是,该系统未得到妥善解决.您需要使用ldivide(\)运算符,而不是rdivide(/).做A/c等同于A*c^{-1},这不是你想要的.要解决系统的解决方案,您必须做A^{-1}*c或等效A\c.此外,为了确保您获得正确的解决方案,c需要是列向量,而不是行向量.我还假设这a是一个未在当前代码中声明的常量.
因此:
syms a; %// Added
A=sym([3/sqrt(29) 3/sqrt(29) -1 0 0 0;
1 -1 0 0 0 0;
4/sqrt(29) 4/sqrt(29) 0 0 0 0;
0 0 1 9/sqrt(101) 0 0;
0 0 0 2/sqrt(101) -1/sqrt(5) 1/sqrt(5);
0 0 0 4/sqrt(101) 2/sqrt(5) 2/sqrt(5)]);
c=sym([0 0 -a 0 0 -a]).'; %// Change
out = A\c;
Run Code Online (Sandbox Code Playgroud)
我明白了:
out =
-(29^(1/2)*a)/8
-(29^(1/2)*a)/8
-(3*a)/4
(101^(1/2)*a)/12
-(5^(1/2)*a)/4
-(5*5^(1/2)*a)/12
Run Code Online (Sandbox Code Playgroud)