Is it possible to integrate over a vector-product? For example:
integral(@(x) [x,1]*[x;1],0,1)
integral(@(x) dot([x;1],[x,1]),0,1)
The problem is how matlab calls your function. Internally something like fkt(0:.1:1) is called, which is not possible with your function. You can wrap your function into arrayfun to get the integral:
fkt=@(x) dot([x;1],[x,1])
afkt=@(a)arrayfun(fkt,a)
integral(afkt,0,1)
While fkt and afkt return the same for a scalar (e.g. fkt(.3)
afkt(.3)
) the function afkt
can deal with vector inputs like afkt(0:.1:1)
to get multiple values at once.