How to Integrate these data ?

Hi All
I have a Diagram of Data x-y like this :
and the integration should look like :
having the Data of the first diagram as :
x=[0: 0.06] , you choose the step
and y = [-0.062847398, -0.057017095, -0.048434094, -0.03892462, -0.030365732, -0.023723144, -0.019435892, -0.017256826, -0.01674607, -0.01734093, -0.018578755, -0.020101786, -0.021674287, -0.023155192, -0.024468152, -0.025585016, -0.026502747, -0.027236393, -0.027807428, -0.02824128, -0.028562468, -0.028794073, -0.028956106, -0.029065736, -0.029136971, -0.029181112, -0.0292069, -0.029220911, -0.029227789, -0.029230507, -0.029230507, -0.029227789, -0.029220911, -0.0292069, -0.029181112, -0.029136971, -0.029065736, -0.028956106, -0.028794073, -0.028562468, -0.02824128, -0.027807429, -0.027236391, -0.026502745, -0.025585016, -0.024468152, -0.023155192, -0.021674288, -0.020101786, -0.018578757, -0.01734093, -0.01674607, -0.017256826, -0.019435894, -0.023723146, -0.030365737, -0.038924627, -0.048434086, -0.057017088, -0.062847398]
How can I integrate on these data so I will have more or less the same final amount of the integration that you see on the second graph : -2e-3 ? I know that my data are not precisely similar as the first graph , but I just would like to know how to do the integration with these data ? thank you

 Respuesta aceptada

pfb
pfb el 14 de Abr. de 2015
Editada: pfb el 14 de Abr. de 2015

1 voto

You could use "cumptrapz". For that you'll need to provide both x and y.
In this respect, what do you mean "you choose the step"? If there is "a step" it will be something like the integration integral over the number of sampled points...

7 comentarios

farzad
farzad el 14 de Abr. de 2015
Thank you , but how do we use quad when we have the vectors , ok I meant the steps be arbitrary , cause I coudn't choose the write amount so the x and y have the same size , but the quad needs a function though !
farzad
farzad el 14 de Abr. de 2015
Thank you , but shall you please tell me how could I do that
pfb
pfb el 14 de Abr. de 2015
Editada: pfb el 14 de Abr. de 2015
strike that. What you need is "cumtrapz".
I always get mixed up with those, sorry.
I'm correcting my reply.
Torsten
Torsten el 14 de Abr. de 2015
Use trapz.
Best wishes
Torsten.
pfb
pfb el 14 de Abr. de 2015
Editada: pfb el 14 de Abr. de 2015
Thorsten, I think he wants the upper bound of integration to run in the whole interval (check the second plot). For that he should use cumtrapz. Trapz would give him a single scalar.
farzad
farzad el 14 de Abr. de 2015
Should I only write :
cumtrapz(y)
??????????
pfb
pfb el 14 de Abr. de 2015
Editada: pfb el 14 de Abr. de 2015
You could read the documentation for cumtrapz, to begin with. Do you want to learn how to do things, or are you just having other people solve your homeworks?????????
The documentation pops up when you type "help cumtrapz" or "doc cumtrapz".
In general the function needs to know the abscissae as well, as I mention above. The result depends on that too. Therefore it should be
I = cumtrapz(x,y);
I think you know the abscissae, otherwise how could you plot the figure in the first place?
If you just need the integral on the whole interval (as opposed to the second plot) you could use trapz, as suggested by Torsten.
I = trapz(x,y);
If you do not want to bother with x, and you know the (fixed) step between subsequent points, you can use
I = dx*trapz(y)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 14 de Abr. de 2015

Editada:

pfb
el 14 de Abr. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by