How can I carve out a region of a 3D matrix given a specific x and y range?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
wbenn7
el 20 de Sept. de 2024
Comentada: wbenn7
el 23 de Sept. de 2024
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 comentarios
Respuesta aceptada
Epsilon
el 23 de Sept. de 2024
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!
Más respuestas (0)
Ver también
Categorías
Más información sobre Point Cloud Processing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!