How to write an integral using 'cumsum'?

조회 수: 6 (최근 30일)
NEELABJA CHATTERJEE
NEELABJA CHATTERJEE 2018년 9월 23일
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