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