laplace inversion and gauss-chebychev quadrature integration in matlab

Laplace Inversion in MATLAB

Laplace inversion in MATLAB can be performed using the ilaplace function, which computes the inverse Laplace transform of a symbolic expression or a polynomial expression. Here's an example:

main.m
syms s t
F = 1 / (s^2 + 4);
f = ilaplace(F);
45 chars
4 lines

This code defines the symbolic variable s and the symbolic variable t, and creates a Laplace transform F of 1 / (s^2 + 4). The ilaplace function then computes the inverse Laplace transform of F, which gives the time domain expression f.

If you have a Laplace transform that is difficult to compute symbolically, you can use the ifourier function to perform the inverse Fourier transform of the Laplace transform. Here's an example:

main.m
syms s t
F = exp(-s*t) / (s^2 + 4);
f = ifourier(F, s, t);
59 chars
4 lines

This code defines s and t as before, and creates the Laplace transform F of exp(-s*t) / (s^2 + 4). The ifourier function then computes the inverse Fourier transform of F with respect to s, which gives the time domain expression f.

Gauss-Chebyshev Quadrature in MATLAB

Gauss-Chebyshev quadrature is a numerical integration technique that is specialized for integrating functions over a finite range. In MATLAB, Gauss-Chebyshev quadrature can be performed using the chebfun package. Here's an example:

main.m
f = @(x) exp(x).*cos(x);
I = chebfun(f, [0, pi], 'vectorize', 'eps', 1e-10);
77 chars
3 lines

This code defines a function f(x) = exp(x)*cos(x) to be integrated over the range [0, pi], and creates a chebfun object I by calling chebfun(f, [0, pi], 'vectorize', 'eps', 1e-10). The vectorize flag tells MATLAB to vectorize the function f so that it can be evaluated on an array of points in the integration range, and the eps flag specifies the error tolerance of the integration.

Once the chebfun object I has been created, its integral can be computed using the built-in sum function:

main.m
integral = sum(I);
19 chars
2 lines

This code computes the integral of I using a built-in sum function, and stores it in the variable integral.

gistlibby LogSnag