Borrar filtros
Borrar filtros

How do i vectorise a function created by spline

1 visualización (últimos 30 días)
Maximilian Jatzkowski
Maximilian Jatzkowski el 7 de En. de 2019
Editada: Jan el 7 de En. de 2019
I have the following functions, created with the help of spline
function c = consumption(v)
load('elbilTesla.mat');
if any(v < speed_kmph(1)) || any(v > speed_kmph(end))
error(['Hastigheten måste vara inom intervallet ', num2str(speed_kmph(1)), ' till ', num2str(speed_kmph(end)), '!']);
else
c = interp1(speed_kmph, consumption_Whpkm, v, 'spline');
end
end
function E = total_consumption(x, route)
load(route);
if any(x < distanceA_km(1)) || any(x > distanceA_km(end))
error(['Sträckan måste vara inom intervallet ', num2str(distance_km(1)), ' till ', num2str(distance_km(end)), '!']);
else
v=interp1(distanceA_km, speedA_kmph, x, 'spline');
E=integral(@(x) consumption(v),0,x,'ArrayValued',true);
end
end
i would like to plot this function and use fzero to input a vector in 'x' and not a single value.
How does one vectorise a function created by spline?
  1 comentario
Maximilian Jatzkowski
Maximilian Jatzkowski el 7 de En. de 2019
Editada: Jan el 7 de En. de 2019
i mistyped, i want to use fzero and therefore need to be able to input a vector into the function

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Splines en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by