Skip to content

Commit

Permalink
fix: ensure the largest grid to be accumulated
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ShijieYan committed Oct 7, 2021
1 parent e5dfd78 commit 24f4698
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions mcxlab/examples/demo_polarized_photon.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 24f4698

Please sign in to comment.