MATLAB: Undefined function or variable ‘cosump’. Error in calc (line 3). what am I doing wrong

function

function cost=calc(consump)
if consump<=160
cost= cosump*33;
elseif (consump>161) && (consump<=300)
cost= 160*33+(cosump-160)*72;
end
end

Best Answer

You have a repeated typographical error, typing ‘cosump’ instead of ‘consump’.
See if this corrected version of your function works:
function cost = calc(consump)
if consump<=160
cost = consump*33;
elseif (consump>161) && (consump<=300)
cost= 160*33+(consump-160)*72;
end
end
Related Question