How to write an integral using 'cumsum'?

6 vues (au cours des 30 derniers jours)
NEELABJA CHATTERJEE
NEELABJA CHATTERJEE le 23 Sep 2018
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.

Réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by