Undefined function or variable 'cosump'. Error in calc (line 3). what am I doing wrong?
Ältere Kommentare anzeigen
function cost=calc(consump)
if consump<=160
cost= cosump*33;
elseif (consump>161) && (consump<=300)
cost= 160*33+(consump-160)*72;
end
end
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 2 Jan. 2018
You're probably typing F5 or hitting the green run triangle to run the code. Doing this does not pass in any value for consump. You would need to have a line of code, either in the command window or an m-file, where you pass in a value. For example, for 50:
cost = calc(50);
1 Kommentar
Muath Zahran
am 2 Jan. 2018
Kategorien
Mehr zu Choose a Solver finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
