Double numerical integration of an Experimental data (no function)
显示 更早的评论
Hi all,
I have a rectangular domain ( in x and y) and have 64 points equally distributed data points around this rectangular domain (lets call the data points as A). I have the numerical value of each point on the grid. (sizes: x = 1 x 64, y = 1 x 64, A = 8 x 8)
B = double_integration(A) dx dy.
I tried the already given solution , result = trapz(x,trapz(y,mat,1),2) , but did not get any result. (Error was, LENGTH(X) must equal the length of Y in dim 1.)
Any ideas?
Many thanks
2 个评论
John D'Errico
2016-8-10
Are the points scattered irregularly around the domain? Or are they on a regular lattice of some sort? Like an 8x8 grid?
Baris Gungordu
2016-8-10
回答(1 个)
Star Strider
2016-8-10
I would use trapz on each dimension of ‘A’:
int_1 = trapz(A);
Result = trapz(int_1)
5 个评论
Baris Gungordu
2016-8-10
编辑:Baris Gungordu
2016-8-10
Star Strider
2016-8-10
I thought ‘A’ is (8x8), and you want to integrate it.
The trapz function integrates a matrix by integrating the columns, creating a vector. The second trapz call integrates the vector to produce the result of the double integration.
What are your data and what do you want to do with them?
John D'Errico
2016-8-10
Think of trapz as a single integration, along one axis of the array. You wanted to do a double integration. The first call to trapz will turn the array into a vector of length 8, integrating down the columns of your array by default. Then the second call will integrate the vector, so doing the outer integral.
Baris Gungordu
2016-8-10
Star Strider
2016-8-10
The trapz function works very well with matrices. It considers each column of a matrix as individual vectors, and integrates them, creating a vector. The second trapz call integrates the vector. I do not know what ‘x’ and ‘y’ are with respect to ‘A’, but you can easily transpose ‘A’ to integrate with respect to each variable in order, if necessary.
类别
在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!