フィルターのクリア

How do i vectorise a function created by spline

1 回表示 (過去 30 日間)
Maximilian Jatzkowski
Maximilian Jatzkowski 2019 年 1 月 7 日
編集済み: Jan 2019 年 1 月 7 日
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 件のコメント
Maximilian Jatzkowski
Maximilian Jatzkowski 2019 年 1 月 7 日
編集済み: Jan 2019 年 1 月 7 日
i mistyped, i want to use fzero and therefore need to be able to input a vector into the function

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSplines についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by