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!

Answers (1)

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

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Tags

Asked:

Yas
on 13 May 2017

Answered:

on 13 May 2017

Community Treasure Hunt

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

Start Hunting!