matlab - Function defined as an integral: trapz? -
i want calculate function p of x,y: p(x,y) defined integral of function of x , y:
p(x,y) = integral(indefinite) of v(x,y) dx
now, if have matrix expressing p
on uniform grid x
, y
, how construct function p
(which should matrix).
obviously if integrated using trapz
, obtain vector:
x=linspace(-1,1,10); v=magic(10); p=trapz(x,v); size(p)
gives 1 10
, not 10 10.
assuming that
- the formula p defined like:
p(x,y) = integral[x0 .. x] v(ξ,y) dξ;
the integration grid
x
×y
uniform, normdx
×dy
;the rows of matrix
v
havex
constant, first row corresponding the smallestx
;
then integral is:
p = cumtrapz(v) * dx;
Comments
Post a Comment