How do i vectorise a function created by spline
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (0)
Siehe auch
Kategorien
Mehr zu Splines finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!