# Numericaly computing an integral in MATLAB [closed]

I have the following integral

$$\int_{-\infty}^{\infty} g(t-\tau) \, \mathrm d\tau$$

where $g(\cdot)$ is a known function, e.g., $g(t) = \sin(t)$, and I want to evaluate its value with MATLAB. How should I do this in discrete form? Thanks.

• But in your example, $\int_{-\infty}^{\infty}\sin(t-\tau)d\tau$ does not exist. – msm Jun 16 '17 at 19:35

Use integral function.

q = integral(g,xmin,xmax)


For example $g(t) = e^{-t}$

$$q = \int_0^{\infty}e^{-t}\mathrm{d}t = 1$$

g = @(t) exp(-t);
q = integral(g,0,Inf)