Is there a simple way (or any inbuilt command) to define the following function in matlab:
$f(a,b,x)=\sum\limits_{i=1}^n b(i)\chi_{[a(i),a(i+1))}(x), $
where $a(i)$ and $b(i)$ are the $i^{th}$ entries of vectors $a$ and $b$ of size $n+1$ and $n$ respectively.
I understand that this function can be defined using loops. But I am looking for something simpler/one line command to define this function (see piecewise).
I don't want to define it manually using the command $piecewise,$ because size of the vectors $a$ and $b$ is quite big.
Thanks in advance
You may try the following:(create m. files)
Hope this helps.