Hi,
To create the 3D array that displays the accumulated intensity at particular co-ordinates, you can create an empty 3D array (filled with zeros), and then loop through the "Intensity" column and add each intensity to its respective co-ordinate. This way, if there are duplicate co-ordinates generated due to rounding, the intensities add up, and empty co-ordinates will have zero intensity.
Here is some sample code to get you started-
% Sample data (replace this with your actual data)
data = rand(31100, 4); % Replace with your actual 2D array
Extract the data -
% Extract columns
intensity = data(:, 1);
X = data(:, 2);
Y = data(:, 3);
Z = data(:, 4);
Define the grid ranges and size -
% Define grid ranges
x_min = floor(min(X));
x_max = ceil(max(X));
y_min = floor(min(Y));
y_max = ceil(max(Y));
z_min = floor(min(Z));
z_max = ceil(max(Z));
% Define the size of the 3D array
x_size = round((x_max - x_min)) + 1;
y_size = round((y_max - y_min)) + 1;
z_size = round((z_max - z_min)) + 1;
% Initialize the 3D array
volume = zeros(x_size, y_size, z_size);
Map the Intensities -
% Map intensities to the 3D grid
for i = 1:length(intensity)
% Calculate grid indices
x_idx = round((X(i) - x_min)) + 1;
y_idx = round((Y(i) - y_min)) + 1;
z_idx = round((Z(i) - z_min)) + 1;
% Accumulate intensity values
volume(x_idx, y_idx, z_idx) = volume(x_idx, y_idx, z_idx) + intensity(i);
end
To plot the 3D grid, "volume", you can refer to this link - https://www.mathworks.com/matlabcentral/answers/1682834-how-can-i-create-a-3d-intensity-map-or-3d-scatter-plot-where-colour-represents-intensity.
Hope this helps!
