作业帮 > 综合 > 作业

matlab小程序(简单 刚学)

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/12 10:13:11
matlab小程序(简单 刚学)

function y=test10_4_3(a,b,x)
flag=-1;
if (a>0)&&(a<1)&&(b>0)&&(b<1)&&(a<b)
    if (x>0)&&(x<a)
        flag=1;
    end
    if (x>=a)&&(x<=b)
        flag=2;
    end
    if (x>b)&&(x<1)
        flag=3
    end
else
    disp('输入的参数不符合条件(0<a<b<1)');
    return;
end
switch flag
    case 1
        y=0
    case 2
        y=(x-a)./(b-a)
    case 3
        y=0
    otherwise
        disp('请保证0<a<b<1');
end
这样会不会更好?
function y=test10_4_3(a,b,x)
y=[];
if (a>0)&&(b
再问: 最后的return是返回值吗?
返回谁的?%>_