簡體   English   中英

3D紅血細胞圖在Matlab中

[英]3D Red Blood cell figure in 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;

這是我試過的代碼,但仍然沒有接近我的期望

嗯,我仍然不太高興(看起來更像是紅蠟高達干酪而不是血細胞),但是哦,好吧:

在此輸入圖像描述

%// 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)
    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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM