How can I carve out a region of a 3D matrix given a specific x and y range?

3 次查看(过去 30 天)
I'm looking analyze a specific area of a 3D data set, and the size of the area needs to be based on the ground sample distance and the number of detectors in the x and y direction of the focal plane:
nx = 600; % # of detectors in x direction
ny = 600; % # of detectors in y direction
GSD = 2; % Whatever GSD in m
x = -GSD*nx/2:GSD*nx/2;
y = -GSD*(ny -1)/2:GSD*(ny-1)/2;
Is there a way I can apply x and y to a x, y, z matrix of data?

采纳的回答

Epsilon
Epsilon 2024-9-23
Hi Wbenn7,
To access a region of a 3D matrix based on two dimensions only, pass a colon operator ‘:’ as the third index to access all the data of the third dimension within the range of the first two dimensions.
Example:
% Provided dimensions
nx = 600;
ny = 600;
GSD = 2;
data = rand(nx, ny, GSD); % Example data matrix
xRange=100:200; % range definition
yRange=200:300;
extractedData=data(xRange,yRange,:); % To extract a given range
for x = xRange
for y = yRange
for z = 1:GSD
data(x, y, z) = x + y + z; % To apply data to a given range
end
end
end
overwrittenData=data(xRange,yRange,:)
Please refer to these documentations for further reference:
Hope it helps!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Point Cloud Processing 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by