Filter löschen
Filter löschen

How do i vectorise a function created by spline

1 Ansicht (letzte 30 Tage)
Maximilian Jatzkowski
Maximilian Jatzkowski am 7 Jan. 2019
Bearbeitet: Jan am 7 Jan. 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 Kommentar
Maximilian Jatzkowski
Maximilian Jatzkowski am 7 Jan. 2019
Bearbeitet: Jan am 7 Jan. 2019
i mistyped, i want to use fzero and therefore need to be able to input a vector into the function

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by