帮忙看看我的这个MATLAB程序到底有没有问题~~

来源:百度知道 编辑:UC知道 时间:2024/06/20 05:49:03
S=solve('5*x1+x2-x3=1','x1+3*x3-x4=2','-x1-x2+5*x4=3','2*x3+4*x4=-1')
disp('x1='),disp(S.x1)
disp('x2='),disp(S.x2)
disp('x3='),disp(S.x3)
disp('x4='),disp(S.x4)

A=[5,1,-1,0;1,0,3,-1;-1,-1,0,5;0,0,2,4];
det(A)
为什么我一运行就会弹出安全警报啊~~
到底有没有错啊~

在我这也没问题。
你把出错提示的内容写出来啊,要不谁知道什么错误啊?

另外顺便说一句,没必要用4句disp来显示。
直接用
[x1,x2,x3,x4]=solve('5*x1+x2-x3=1','x1+3*x3-x4=2','-x1-x2+5*x4=3','2*x3+4*x4=-1')
就可以显示出数值结果了。

>> [x1,x2,x3,x4]=solve('5*x1+x2-x3=1','x1+3*x3-x4=2','-x1-x2+5*x4=3','2*x3+4*x4=-1')

x1 =

7/5

x2 =

-59/10

x3 =

1/10

x4 =

-3/10

程序没问题,运行结果:
S =

x1: [1x1 sym]
x2: [1x1 sym]
x3: [1x1 sym]
x4: [1x1 sym]

x1=
7/5

x2=
-59/10

x3=
1/10

x4=
-3/10

ans =

70