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?
0 件のコメント
採用された回答
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:
Array indexing: https://www.mathworks.com/help/matlab/math/array-indexing.html
Multidimensional arrays: https://www.mathworks.com/help/matlab/math/multidimensional-arrays.html
Hope it helps!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Point Cloud Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!