From 24f4698335da4bc7d5ce1d80725453c15ccb2a98 Mon Sep 17 00:00:00 2001 From: ShijieYan Date: Thu, 7 Oct 2021 14:40:20 -0400 Subject: [PATCH] fix: ensure the largest grid to be accumulated Note that idx1d array may not contain the index of the largest grid, which is 10000. In this case, the reshape will complain about the mismatched dimension. --- mcxlab/examples/demo_polarized_photon.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mcxlab/examples/demo_polarized_photon.m b/mcxlab/examples/demo_polarized_photon.m index 568094f8..6dfbe96a 100644 --- a/mcxlab/examples/demo_polarized_photon.m +++ b/mcxlab/examples/demo_polarized_photon.m @@ -82,10 +82,9 @@ % output 2D maps (100x100) for I Q U V ix=discretize(detphoton1.p(:,1),0:0.2:20); iy=discretize(detphoton1.p(:,2),0:0.2:20); -idx1d=sub2ind([100,100],iy,ix); HIQUV1=zeros(4,100,100); for i=1:4 - HIQUV1(i,:,:)=reshape(accumarray(idx1d,s2(:,i)),[100,100]); + HIQUV1(i,:,:)=accumarray([iy,ix],s2(:,i),[100,100]); end % plot @@ -135,10 +134,9 @@ % output 2D maps (100x100) for I Q U V ix=discretize(detphoton2.p(:,1),0:0.2:20); iy=discretize(detphoton2.p(:,2),0:0.2:20); -idx1d=sub2ind([100,100],iy,ix); HIQUV2=zeros(4,100,100); for i=1:4 - HIQUV2(i,:,:)=reshape(accumarray(idx1d,s2(:,i)),[100,100]); + HIQUV2(i,:,:)=accumarray([iy,ix],s2(:,i),[100,100]); end % plot