3D红血细胞图在Matlab中

时间:2014-03-07 08:16:01

标签: matlab

大家好,我在垫子实验室里一直在研究红血细胞3D模型,我想出的是一个扁平的球体,我想在球体的两侧做一个凹陷来得出至少是一个真实的红血球我的代码如下,我应该添加什么来制作一个真实的红细胞模型?

a=1;
c=5;
[u,v]= meshgrid(0:10:360);
x=(a-c*cosd(v)).*cosd(u);
y=(a - c*cosd(v)).*sind(u);
z=a*sind(v);
surf(x,y,z)
axis equal;

这是我尝试过的代码,但仍然没有接近我的预期

2 个答案:

答案 0 :(得分:3)

嗯,我对它仍然不太满意(看起来更像是red-wax Gouda cheese而不是血细胞),但是哦,好吧:

enter image description here

%// Parameters:
a = 0.2; %// Z in the middle
b = 0.8; %// Z at the edge
c = 5;   %// diameter of the bloodcell
n = 50;  %// number of pionts to use on the surf

%// This is copied largely from sphere()
theta = pi * (-1:2/n:1);
phi   = pi/2 * (-1:2/n:1).';

cosphi   = cos(phi);     cosphi(1)   = 0;   cosphi(n+1)   = 0;
sintheta = sin(theta);   sintheta(1) = 0;   sintheta(n+1) = 0;

%// (except for this part)
A = bsxfun(@power, [0; pi/4; pi/2; 3*pi/4; pi], 4:-1:0);
b = [0; b; a; b; 0];
C = A\b;
F = @(phi) sign(phi) .* reshape( (bsxfun(@power, mod(phi(:),pi), 4:-1:0))*C, size(phi) );

x = c * cosphi*cos(theta);
y = c * cosphi*sintheta;
z = F(phi) * ones(1,n+1);


%// Now make the awesome plot
surf(x,y,z,abs(z), 'edgecolor', 'none')
axis equal, grid off, axis off

map = [linspace(0.5,1,n).', zeros(n,1), zeros(n,1)];
colormap(map)

set(gcf, 'Renderer', 'OpenGL');
shading interp, material shiny, lighting phong, lightangle(0, 55)

答案 1 :(得分:0)

    rouleaux = 0;
halfplot = 1;
[X,Y,Z]=sphere(200);
figure(gcf);
clf
Z = Z.*(0.1+0.4.*(X.^2+Y.^2).^1);
th=atan2(X,Y);
if halfplot
    %surfl(   X,Y,Z./( (th>(pi/4+0.1)) + (th<(-3+pi/4)).*(th>(-3*pi/4-1)) )   );
     surfl(   X,Y,Z./((th<pi/4+0.1).*(th>-3*pi/4+0.1))    );
else
    surfl(X,Y,Z);
end
if rouleaux
    hold on
    surfl(X+0.1,Y-0.1,Z+0.5);
    surfl(X+0.1,Y+0.1,Z-0.5);
    surfl(X-0.1,Y,Z-1);
    surfl(X,Y-0.15,Z-1.5);
end
shading interp;
axis equal
grid off;
whitebg('k')
set(gcf,'color','k')
axis off
colormap hot
light
caxis([-0 1.25])
view([176 14])
hold off;