Mathematica中文论坛-非官方

标题: 豆粑粑 matlab 在圆形的区域内contourf,再挖掉一部分 [打印本页]

作者: meatball1982    时间: 2017-5-25 09:50
标题: 豆粑粑 matlab 在圆形的区域内contourf,再挖掉一部分

别人的问题,在一个圆里面画contourf的图,再挖去一块。

http://www.ilovematlab.cn/forum. ... p;extra=#pid3221245


  1. clear all
  2. clc
  3. clf

  4. [x,y,z]=peaks(40);
  5. r_big=linspace(0,3,400);
  6. the=linspace(0,2*pi,720);
  7. the=[2*pi,the];

  8. [R_big,The]=meshgrid(r_big,the);
  9. X_cir_big=R_big.*cos(The);
  10. Y_cir_big=R_big.*sin(The);

  11. Z_cir_big=griddata(x(:),y(:),z(:),X_cir_big,Y_cir_big);

  12. Cir_big_x =r_big(end)*cos(the);
  13. Cir_big_y =r_big(end)*sin(the);


  14. r_sma=0.9;
  15. cen_x=-1.7;
  16. cen_y=0.3;

  17. Cir_sma_x =r_sma*cos(the)+cen_x;
  18. Cir_sma_y =r_sma*sin(the)+cen_y;



  19. ind=((X_cir_big-cen_x).^2+(Y_cir_big-cen_y).^2)<r_sma^2;

  20. % X_cir_big(ind)=nan;
  21. % Y_cir_big(ind)=nan;
  22. Z_cir_big(ind)=nan;
  23. hold on
  24. % surf(X_cir_big,Y_cir_big,Z_cir_big,'edgecolor','none');
  25. [C,h]=contourf(X_cir_big,Y_cir_big,Z_cir_big,20,'linecolor','k','linestyle','--');
  26. clabel(C,'fontSize',8)
  27. colorbar
  28. plot(Cir_big_x,Cir_big_y,'k','linewidth',1)
  29. plot(Cir_sma_x,Cir_sma_y,'k','linewidth',1)
  30. axis equal
  31. axis off
  32. colormap(jet)
  33. h=gcf;
  34. fi_na=['./fig_cont_2D'];
  35. fun_work_li_035_myfig_out(h,fi_na,3);
复制代码









欢迎光临 Mathematica中文论坛-非官方 (http://ilovemathematica.com/) Powered by Discuz! X3.2