You are not using input variable v and assigning a value to output variable c inside the function body. From the context of your question, the correct function definition is
function c = consumption(v) load roadster.mat; x = 2:2:200; y = consumption_Whpkm; xx=2:200; pp=spline(x,y); plot(xx, ppval(pp, xx),'k-',x,y,'ro'); c = ppval(pp, v); % assigning value to output for input v end
