Extract slice data from 3D scalar field into a N by M array for integration in Matlab

2 次查看(过去 30 天)
I am looking to extract data on a plane of a scalar field in Matlab so that I can integrate over the area of the slice and find the average quantity.
Is it possible to use the slice tool in Matlab to get the 3D data that intersects with my slice into an N*M array, where each index represents the location in space? My goal is to eventually integrate over the surface (the slice) to find the average value of the scalar quantity.
I know that I can call a vector of handles h = slice(...) but I'm not very familiar with the slice tool, so I don't know what to input and then what handles will be useful.
Also, I would like to define my slice by 4 vertices a,b,c, and d which I have already defined. Is this possible or do I need to input 3 'position' vectors that define the location of each edge of my slice?
Thanks in advance!

回答(2 个)

John
John 2016-11-12
I second the question and hope to receive answer. Thanks.

Walter Roberson
Walter Roberson 2016-11-12
No. slice does not generally extract rectangular matrices of data because generally you are using a projection that is oblique relative to one or more of the major axes.
In the particular case where you are wanting to find a cuboid sub-volume, figure out the bounding array indices and use array indexing. For example,
row_a = find(vector_of_x >= a, 1, 'first');
row_b = find(vector_of_x <= b, 1, 'last');
and then YourData(row_a : row_b, :, :)
(provided that you have x in rows, which might not be the case as x is generally columns, but you can easily adapt.)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by