Azzera filtri
Azzera filtri

intersections of all combinations of pairs of matrices in 3D array

1 visualizzazione (ultimi 30 giorni)
Hello, I have a 3D array "array_ellipsoid" of size(40000,3,5000). this array represents 5000 ellipsoids that intersect in 3D space. I need to find the intersection between all combinations of pairs of matrices in this array. for example, A=array_ellipsoid(:,:,1), B=array_ellipsoid(:,:,2), C=array_ellipsoid(:,:,3),...., Z=array_ellipsoid(:,:,5000), then I need to get an array to get all possible intersections between "A,B" and "A,C" and "B,C",etc... for all combined pairs. I already do this by nested for and if loops but it takes huge processing time. I was wondering if there is a faster and smarter way to do it in shorter time and avoid the unnecessary nested loop processing time consumption.Please find below the sample code.thanks in advance.
intersect_pts=30;
array_intersect=nan(intersect_pts,3,5000,5000);
load('D:\array_ellipsoid.mat')
for i=1:5000
for j=1:5000
if i~=j
intersect_data=intersect(array_ellipsoid(:,:,i),array_ellipsoid(:,:,j),'rows');
if isempty(intersect_data)==0 && size(intersect_data,1)<=intersect_pts
array_intersect(1:size(intersect_data,1),:,i,j)=intersect_data;
elseif isempty(intersect_data)==0 && size(intersect_data,1)>intersect_pts
array_intersect(:,:,i,j)=intersect_data(1:intersect_pts,:,:);
end
end
end
array_intersect_final=permute(reshape(permute(array_intersect,[2 1 3 4]),[3 intersect_pts*5000*5000]),[2 1 3]);

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by