|
本帖最后由 meatball1982 于 2019-3-16 15:04 编辑
是让孩子们作的,我给整一下先。
这两天写本子,画几个小图,放松一下。
你的有一个分子。
我是从pdb 里把位置给提出来。
设置一个球,以原子位置为球心,放球。
在空间中有很多的点。
通过boundary(真是个好函数,比较新的版本才有)。实现2D和3D边界的显示。
- clear all
- clc
- clf
- dat=load('../file_data/pos_ala.txt');
- x=dat(:,1);
- y=dat(:,2);
- z=dat(:,3);
- [sx,sy,sz]=sphere(50);
- r=2.2;
- n_p=length(x);
- x_all=[];
- y_all=[];
- z_all=[];
- for i =1:n_p
- % rat = 1+0.03*i;
- rat = 1;
- sx_new=rat*r.*sx;
- sy_new=rat*r.*sy;
- sz_new=rat*r.*sz;
- x_all=[x_all;dat(i,1)+sx_new(:)];
- y_all=[y_all;dat(i,2)+sy_new(:)];
- z_all=[z_all;dat(i,3)+sz_new(:)];
- end
- %
- axis equal
- subplot(2,2,1)
- plot3(x_all,y_all,z_all,'.','markersize',3);
- view(90,17.6)
- axis off
- axis tight
- subplot(2,2,2)
- [k_all3 ]=boundary([x_all,y_all,z_all],0.8);
- trisurf(k_all3,x_all,y_all,z_all,'facecolor','red','facealpha',0.2,'edgecolor','y','edgealpha',0.2)
- view(90,17.6)
- axis off
- axis tight
- subplot(2,2,3)
- lin = linspace(-4,4,8);
- lin =[ -3 -2.5 -2 -1.5 -1 -0.5 0 1 2 3 4 5 6 7 8 9 10 ]
- n_l = length(lin)
- col_mm = jet(n_l);
- hold on
- for i = 1:n_l
- lb = lin(i)-0.2;
- ub = lin(i)+0.2;
- ind = z_all > lb & z_all < ub;
- tm_x = x_all(ind);
- tm_y = y_all(ind);
-
- k_all=boundary([tm_x,tm_y],0.99-0.02*i);
-
-
- plot3(tm_x(k_all),tm_y(k_all),lin(i)*ones(size(k_all)),'-','linewidth',1+0.3*i,'color',col_mm(i,:))
-
- end
- view(90,17.6)
- axis equal
- axis off
- axis tight
- subplot(2,2,4)
- lin = linspace(-4,4,8);
- lin =[ -3 -2.5 -2 -1.5 -1 -0.5 0 1 2 3 4 5 6 7 8 9 10 ]
- n_l = length(lin)
- col_mm = jet(n_l);
- hold on
- for i = 1:n_l
- lb = lin(i)-0.2;
- ub = lin(i)+0.2;
- ind = z_all > lb & z_all < ub;
- tm_x = x_all(ind);
- tm_y = y_all(ind);
-
- k_all=boundary([tm_x,tm_y],0.99-0.02*i);
-
-
- h=patch(tm_x(k_all),tm_y(k_all),lin(i)*ones(size(k_all)),col_mm(i,:),'edgecolor','none')
- alpha(h,0.8-0.02*i);
-
-
- end
- view(90,17.6)
- axis equal
- axis off
- axis tight
- h=gcf;
- fi_na = '../file_imgs/fig_cont_ala_4sub';
- fun_work_li_035_myfig_out(h,fi_na,3)
复制代码
|
|