definite integral of numerical vectors

i'm looking for to solve a definite integral of two vectors
I know: z vector of numbers and G(z) vector of numbers. The limits of integration are zmin and zmax
I should to calculate: Integral between zmin,zmax of [G(z) * z^(7/6)] dz

 Respuesta aceptada

Mahesh
Mahesh el 16 de Jul. de 2014

2 votos

I think you have to use numerial method of integration such as simpson rule or trapezoidal rule. Make a routine for either of these methods and calculate them for each z values and add up. If sum over them, you will get the answer. I hope it works for you. Let me know if you have problem on making subroutine.
Goof luck.

5 comentarios

Star Strider
Star Strider el 16 de Jul. de 2014
If you have vectors of numbers rather than functions, integral will not work. As Mahesh suggests, use the trapz function instead.
Stefano
Stefano el 16 de Jul. de 2014
Editada: Stefano el 16 de Jul. de 2014
Thank you, could you give me an example? I would to obtain another vector as result
The way you have defined your data (as I understand it anyway), you have one vector created by multiplying element-by-element the vector for G(z) (that you have already defined as a vector) and the vector z^(7/6). Integrating it will only give you a vector if you use cumtrapz.
This is how I understand what you want to do:
zmin = 0;
zmax = 100;
z = linspace(zmin,zmax); % Create ‘z’ (arbitrary)
Gz = exp(-z); % Create ‘G(z)’ (arbitrary)
Dg = [Gz .* z.^(7/6)]; % Create vector to integrate
Ig = trapz(z, Dg) % Do the integration
The value of the integral is returned in Ig.
If G(z) is an array instead of a vector, Ig will be a vector.
Stefano
Stefano el 18 de Jul. de 2014
Thank you!
Star Strider
Star Strider el 18 de Jul. de 2014
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 16 de Jul. de 2014

Comentada:

el 18 de Jul. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by