matlab 报错Conversion to logical from sym is not possible.无法从 sym 转换为 logical.M文件function [y] = f (x) if x>=0 && x<=1/2 y = 2*x; elseif x>1/2 && x<=1 y = 2*(1-x); endend

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/29 01:52:14
matlab报错Conversiontologicalfromsymisnotpossible.无法从sym转换为logical.M文件function[y]=f(x)ifx>=0&&a

matlab 报错Conversion to logical from sym is not possible.无法从 sym 转换为 logical.M文件function [y] = f (x) if x>=0 && x<=1/2 y = 2*x; elseif x>1/2 && x<=1 y = 2*(1-x); endend
matlab 报错Conversion to logical from sym is not possible.无法从 sym 转换为 logical.
M文件

function [y] = f (x)
    if x>=0 && x<=1/2
        y = 2*x;
    elseif x>1/2 && x<=1
        y = 2*(1-x);
    end
end

matlab 报错Conversion to logical from sym is not possible.无法从 sym 转换为 logical.M文件function [y] = f (x) if x>=0 && x<=1/2 y = 2*x; elseif x>1/2 && x<=1 y = 2*(1-x); endend
M文件
function [y] = f (x)
if x>=0 && x1/2 && x