How to write an integral using 'cumsum'?

6 次查看(过去 30 天)
I want to write this discretized integral in MatLab using 'cumsum'.
I tried the following (where i0 = find(x==0))
Pp=Dx*cumsum(u(i0:end));
Pm=-Dx*[fliplr(cumsum(fliplr(u(1:i0-1)))) 0];
P=[Pm Pp];
Pk=0.5*(P(1:end-1)+P(2:end));
to compute $ \int_{-1}^{1} u(y,t) dy$ (for a fixed, to be evolved later time level; the integral from -1 to 1 of the function u(x,t)dx.) Now I want to compute [integral from 0 to x of the function u(y,t)dy] - [integral from 0 to 1 integral from 0 to y of the function u(z,t)dzdy] ~ I have attached the discretized form here with.
Any kind of help regarding this coding would be much appreciated.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by