(I'm very new to programming). I want my code to give me the consumption for every speed. So when I for example write consumption(40) in the command window it gives me the consumption for when the speed is 40 km/h.
This is my code so far:
function c = consumption(v)
load roadster.mat;
x = 2:2:200;
y = consumption_Whpkm;
xx=2:200;
pp=spline(x,y,xx);
plot(xx,spline(x,y,xx),'k-',x,y,'ro')
end
Best Answer
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