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!

Réponses (1)

Walter Roberson
Walter Roberson le 13 Mai 2017

0 votes

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()

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by