I'm trying to prevent extrapolation, the input speed (v) can't be lower than 2 or higher than 200. I'm trying to use if/else but I'm being told by a "test-programme" that "Function does not result in error when input results in extrapolation". What am I doing wrong?
My code:
function c = consumption(v)
load roadster.mat;x = 2:2:200;y = consumption_Whpkm;xx=2:200;pp=spline(x,y);c = ppval(pp, v);if v<2 | v>200 error ('Too fast/slow')else contineend
end
Best Answer