Question on how to calculate integral

Hello everybody,
I have a question on how to calculate integral of a matrix in Matlab. I have the following code and wants to calculate the integral of A. Do I calculate the integral (area below the curve) correct?
I wanted to calculate the integral from -infinity to +infinity and also -infinity to T....
dt=0.025; %--time step
T=(-30:dt:30)';%(-5:dt:5)'; %-- dimensionless time vector
t=T;
nt=length(T);
T2=9.1093;
A=(exp((-T.^2)/(2*((T2).^2))));
Integral=abs(sum(A))*dt
Thank you!

Respuestas (1)

Walter Roberson
Walter Roberson el 13 de Mayo de 2017

0 votos

Not exactly: when you do a finite range, you need a correction at the edges. trapz() does the edge correction.
For infinite intervals you should construct an anonymous function and use integral()

Categorías

Más información sobre Numerical Integration and Differential Equations en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Yas
el 13 de Mayo de 2017

Respondida:

el 13 de Mayo de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by