热线电话:13121318867

登录
2019-02-15 阅读量: 822
为什么我的函数只显示一个输出变量?

我在命令窗口中调用我的函数时,我应该向out1,out2和out3吐出来。但只显示out1。为什么?

function [out1, out2, out3] = testSystem(in1, in2, in3)

b = [in1; in2; in3];

A = [2, 1, 1;

-1, 1, -1;

1, 2, 3;];

x = A\b;

disp(x);

out1 = x(1,1);

out2 = x(2,1);

out3 = x(3,1);

end

>> testSystem(2,3,-10)

3

1

-5

ans =

3

解决办法:

因为你不分配输出。因此,该函数仅返回第一个输出。如果你打电话[out1, out2, out3] = testSystem(2,3,-10),它应该做你想要的。

0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子