Spline and interpolation?
Mostrar comentarios más antiguos
(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
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 22 de Abr. de 2018
0 votos
You need to use v inside your function. Please see attached spline demo.
Categorías
Más información sobre Splines en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!