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/05/16 04:39:20
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); 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