Hi, I am trying to add multiple 3D-arrays to a bigger 3D-array at a specific index (x,y,z)
Below is the code, and it does work and compute the answer but it seems very ineffecient.
In this example, i only have 4 sets of coordiantes (x,y,z) but in real code, i have more than 1e6 sets of points.
It takes very long to compute the result with that many points.
Is there any way to reduce the computation time?
Thank you in advance
Regards
J
Big=zeros(500,500,500); %%%% Bigger Array
Small=rand(250,250,250);x=[245; 220; 256; 270];y=[245; 220; 256; 270];z=[245; 220; 256; 270]; for n = 1 : length(x) x_cord=x(n)-length(Small)/2; y_cord=y(n)-length(Small)/2; z_cord=z(n)-length(Small)/2; x_end= x_cord + length(Small) -1 ; y_end= y_cord + length(Small) -1; z_end=z_cord + length(Small) -1; if x_end <= length(Big) Big(x_cord:x_end, y_cord:y_end,z_cord:z_end)=Big(x_cord:x_end, y_cord:y_end,z_cord:z_end)+Small(); end end
Best Answer