Indefinite integral for a step function with variable number of steps

2 ビュー (過去 30 日間)
Hello friends,
I have a function handle which is defined by interp1. Is there a way to find its indefinite integral?
For instance
x0=[1 2 5 7 10];y0=[2 1 3 2]; f=@(x)interp1(x0,y0,x,'previous');
Please note the above example is just a simple case (I know how to handle this easy case). My function is a step function with many steps where the number of steps are not known to me beforehand. So, in general my function is defined by f=@(x)interp1(mesh,c,x,'previous'); where mesh is my x-data, c is a vector of steps or y-data. How to find the indefinite integral of this function?
Thanks in advance!
Babak

採用された回答

Torsten
Torsten 2022 年 6 月 1 日
The definite integral between a and b where mesh(1) <= a < b <= mesh(end) can be computed as for every other function as
value_integral = integral(f,a,b)
where
f = @(x)interp1(mesh,c,x,'previous')
  3 件のコメント
Torsten
Torsten 2022 年 6 月 1 日
y0 has only 4 elements. It must be of the same size as x0 - thus have 5 elements.
Mohammad Shojaei Arani
Mohammad Shojaei Arani 2022 年 6 月 1 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by