我自己写的函数为什么是错的?
function =yzfun(x)a = randn(2,1);
if a(1)*a(2)>=0
y = a(1)*x;
else
z = a(2)*x;
endError in yzfun (line 2)
a = randn(2,1);
Output argument "z" (and maybe others) not assigned during call to "E:\Matlab\yzfun.m>yzfun".
输出变量数量不对,比如修改为
function =yzfun(x)
a = randn(2,1);
if a(1)*a(2)>=0
y = a(1)*x;
z = 0;
else
y = 0;
z = a(2)*x;
end
页:
[1]