I would like to draw a 4d isosurfce plot, where the 4th dimension, is the density of each grid voxel, and I would like it to be thee isovalue
Info
This question is closed. Reopen it to edit or answer.
Show older comments
M is a 3d grid of points.
Ro(t) is the density at grid point t.
Ro3D is thee density at each pixel as a 3D matrix that corrwesponds to each voxel.
How would you plot it?
Thank you!
M=DataSRX(find(idx==1),4:6);
StepSize=100; % [nm]
Xgrid=min(M(:,1)):StepSize:max(M(:,1));
Ygrid=min(M(:,2)):StepSize:max(M(:,2));
Zgrid=min(M(:,3)):StepSize:max(M(:,3));
Sigma=StepSize;
XGsize=numel(Xgrid); YGsize=numel(Ygrid); ZGsize=numel(Zgrid);
Z=zeros(1,XGsize*YGsize*ZGsize);
Ind=zeros(size(M,1),1);
Ro=Z;
% Z(1)=Xgrid(1),Ygrid(1),Zgrid(1); Z(2)=Xgrid(2),Ygrid(2),Zgrid(2);
% Z(Xn)=Xgrid(Xn),Ygrid(1),Zgrid(1); Z(Xn+1)=Xgrid(1),Ygrid(2),Zgrid(1);
Norm=1./((Sigma*sqrt(2*pi)^3));
for i=1:size(M,1)
tx=ceil((M(i,1)-min(M(:,1)))/StepSize); ty=ceil((M(i,2)-min(M(:,2)))/StepSize); tz=ceil((M(i,3)-min(M(:,3)))/StepSize);
if ty==0
ty=1;
end
if tx==0
tx=1;
end
if tz==0
tz=1;
end % if tz==0
t=(XGsize+YGsize)*(tz-1)+XGsize*(ty-1)+tx;
Z(t)=Z(t)+1;
Ind(i)=t;
Ro(t)=Norm*exp(((M(i,1)-Xgrid(tx))^2+(M(i,2)-Ygrid(ty))^2+(M(i,3)-Zgrid(tz))^2)/(2*Sigma^2))+Ro(t);
end % for i=1:size(M,1)
RoDense=Ro.*Z;
Ro3D=reshape(RoDense,[XGsize,YGsize,ZGsize]);
%{
Ro3D=zeros(XGsize,YGsize,ZGsize);
for i=1:numel(Ro)
[I,J,K]=ind2sub([XGsize,YGsize,ZGsize],i);
Ro3D(I,J,K)=Ro(i);
end % for i=1:numel(Ro)
%}
Ro3D_round=round(Ro3D,3);
Answers (1)
Guy Nir
on 18 Jun 2019
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!