How to write an integral using 'cumsum'?
Mostrar comentarios más antiguos

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.
Respuestas (0)
Categorías
Más información sobre Numerical Integration and Differentiation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!