how to overlay multiple images using scatter3?
Mostrar comentarios más antiguos
I want to plot two ellipsoids.
%making axes
Sx=1; Sy=1; Sz=1; Nx=50; Ny=50; Nz=50; dx= Sx/Nx; dy=Sy/Ny; dz=Sz/Nz;
xa=[0:Nx-1]*dx;
ya=[0:Ny-1]*dy;
za=[0:Nz-1]*dz;
xa=xa-mean(xa);
ya=ya-mean(ya);
za=za-mean(za);
[X,Y,Z]=meshgrid(xa,ya,za);
%bigger ellipsoid
rx=0.5;
ry=0.35;
rz=0.2;
A=zeros(length(xa),length(ya),length(za));
A(((X/rx).^2+(Y/ry).^2+(Z/rz).^2)<=1)=1;
A(((X/rx).^2+(Y/ry).^2+(Z/rz).^2)>1)=NaN;
%plotting by scatter3
figure, scatter3(X(:),Y(:),Z(:),[],A(:)), colormap cool, axis equal, axis tight, grid on;
hold on;
%smaller ellipsoid with half radius
rx=rx/2;
ry=ry/2;
rz=rz/2;
A2=zeros(length(xa),length(ya),length(za));
A2(((X/rx).^2+(Y/ry).^2+(Z/rz).^2)<=1)=0;
A2(((X/rx).^2+(Y/ry).^2+(Z/rz).^2)>1)=NaN;
%plotting smaller one by scatter3
scatter3(X(:),Y(:),Z(:),[],A2(:));
hold off;
But the the latter scatter3 function doesn't make any change. When I only run the code:
scatter3(X(:),Y(:),Z(:),[],A2(:));
then smaller ellipsoid is shown. When the whole code run, only the bigger one is shown. What's the problem?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Surface and Mesh Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
