How to integrate using trapz function

Hi I am using trapz to get my answer. but i am getting 0 which is not the answer. I have attched my data where Y reprsesnt loads (mg/hr) and x represents time in a number form . Please i will extremely graeful if somebody can help.
Int=trapz(X1,Y);

 Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 31 de Ag. de 2022
The variable in X1 seems awfully constant, at 0.0166. The first input to trapz should be the x-coordinate of the points at which you have Y, not the values of "dx". Perhaps what you want is something like:
Ival = trapz(cumsum(X1),Y);
HTH

4 comentarios

shagun chaudhary
shagun chaudhary el 31 de Ag. de 2022
Thank you so much
shagun chaudhary
shagun chaudhary el 31 de Ag. de 2022
Hi,
How should i write if I have one row of X1 value (1X525595) as shown above but Y row consist of (56X525595). I need int (trapz) for all the 56 combination. Please can you help on this.
shagun chaudhary
shagun chaudhary el 31 de Ag. de 2022
How to get Trapz for all 56 combination. This is what ineed. Thanks
If you look at the help for trapz you will read:
Z = trapz(X,Y,DIM) or trapz(Y,DIM) integrates across dimension DIM
of Y. The length of X must be the same as size(Y,DIM)).
That means that your call to trapz would be something like:
z_all = trapz(cumsum(X1),Y,2);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by