LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you integrate a column with respect to another column

I have two columns of data, one is time and the other is velocity. I want to be able to integrate velocity with respect to time, but I can not find a function which will let me do this. Preferably, I'd like to do a cumulative trapezoidal integration, such as the one in Matlab. The function "cumtrapz" does not work the same in mathscript as it does in matlab. The "trapz" function did not seem to integrate the columns in the way that I wanted it to, leaving me with just a number.

 

Is there any way I can recreate the "cumtrapz" function from Matlab in Mathscript?

 

Thanks.

0 Kudos
Message 1 of 2
(6,194 Views)

The cumtrapz in MathScript can not accept a time array as input. Then, you have to write your own script to calculate the cumulative trapezoid integration. For example, the following script generates a sin wave and calculates the cumulative trapezoidal integration.

 

t = 0:0.1:pi;
x = sin(t);
y = 0.5*(x(1:(end-1))+x(2:end)).*(t(2:end)-t(1:(end-1)));  %trapizoidal integration
y = cumsum(y);  %cumulative sum

 

 

0 Kudos
Message 2 of 2
(6,189 Views)