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

3 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Epsilon
Epsilon am 23 Sep. 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:
Hope it helps!

Weitere Antworten (0)

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by