Mathematica中文论坛-非官方

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 6530|回复: 0
打印 上一主题 下一主题

豆粑粑,极坐标 非凸 3D曲面. 从不同角度看,显示全曲面

[复制链接]

532

主题

603

帖子

3035

积分

论坛元老

Rank: 8Rank: 8

积分
3035
跳转到指定楼层
楼主
发表于 2017-3-28 13:49:41 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 meatball1982 于 2017-3-28 13:52 编辑

别人的问题
http://www.ilovematlab.cn/forum. ... 1&extra=#pid3168135

最近觉得一个3D图从不同的角度看,效果相当的好。
帖子中只是要画出环的部分,将原曲面通过透明的方式显示。似乎效果更加的好。




  1. clear all
  2. clc
  3. clf

  4. r=linspace(1,1.5,50);
  5. the=linspace(0,2*pi,200);
  6. the=[the,0];

  7. [R,The]=meshgrid(r,the);
  8. x=R.*cos(The);
  9. y=R.*sin(The);

  10. X=x+2;
  11. Y=y+2;
  12. Z=X.*Y;

  13. x_g=linspace(0.5,3.5,100);
  14. y_g = linspace(0.5,3.5,100);
  15. [X_g,Y_g]=meshgrid(x_g,y_g);
  16. Z_g =X_g.*Y_g;

  17. sbp_width=0.75;
  18. sbp_heig=0.75;
  19. n_row = 2;
  20. n_col = 2;
  21. [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);
  22. h=figure(1)
  23. set(h, 'Position', [100, 100, 400, 400]);
  24. ax=axes('position',out_pos(1,:));
  25. hold on

  26. h=surf(X_g,Y_g,Z_g,'edgecolor','none')
  27. alpha(h,0.2)
  28. surf(X,Y,Z,Z,'edgecolor','none')

  29. colormap(jet)
  30. % colormap(h2,cool)
  31. view(-20,20)
  32. axis tight
  33. grid on

  34. ax=axes('position',out_pos(2,:));
  35. hold on
  36. h=surf(X_g,Y_g,Z_g,'edgecolor','none')
  37. alpha(h,0.2)
  38. surf(X,Y,Z,Z,'edgecolor','none')
  39. colormap(jet)
  40. axis equal tight
  41. view(0,90)

  42. ax=axes('position',out_pos(3,:));
  43. hold on
  44. h=surf(X_g,Y_g,Z_g,'edgecolor','none')
  45. alpha(h,0.2)
  46. hsurf(X,Y,Z,Z,'edgecolor','none')
  47. colormap(jet)
  48. axis tight
  49. view(0,0)
  50. grid on

  51. ax=axes('position',out_pos(4,:));
  52. hold on
  53. h=surf(X_g,Y_g,Z_g,'edgecolor','none')
  54. alpha(h,0.2)
  55. surf(X,Y,Z,Z,'edgecolor','none')
  56. colormap(jet)
  57. axis tight
  58. view(-90,0)
  59. grid on



复制代码


其中的
  1. fun_mm_subplot_pos
复制代码
可以用subplot函数来代替,不过我觉得我的更加好些。

  1. function [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);

  2. % subplot pos
  3. % input : -----------------
  4. % n_row     : number of row
  5. % n_col     : number of column
  6. % sbp_width : subplot width  0-1
  7. % sbp_heig  : subplot height 0-1
  8. % output : ----------------
  9. % out_pos
  10. %
  11. %
  12. % sbp_width=0.8;
  13. % sbp_heig=0.85;
  14. % n_row = 4;
  15. % n_col = 6;
  16. % [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);
  17. % h=figure(1)
  18. % set(h, 'Position', [100, 100, 800, 600]);
  19. % [x,y,z]=peaks(30);
  20. % caxis_mm=[-5 30];
  21. % for i=1:n_row*n_col
  22. %     ax=axes('position',out_pos(i,:));
  23. %     surf(x,y,z+i,'edgecolor','none')
  24. %     caxis(caxis_mm)
  25. %     view(0,90)
  26. %     hold on
  27. %     text([2],[2],[30],mat2str(i),'fontsize',20)
  28. % end

  29. for i=1:n_row*n_col

  30.     k1=ceil(i/n_col);
  31.     k2=i-(k1-1)*n_col;
  32.    
  33.     out_pos(i,:)=[(1-sbp_width)/n_col/2 + (k2-1)/n_col,...
  34.                   (1-sbp_heig )/n_row/2 + (n_row-k1)/n_row, ...
  35.                   sbp_width/n_col,...
  36.                   sbp_heig/n_row];
  37. end
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|Mathematica中文论坛-非官方 ( 辽ICP备16001491号-1

GMT+8, 2024-5-4 10:47 , Processed in 0.121609 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表