实例:可设置函数曲线光源的用户界面

[复制链接]
 楼主| cooldog123pp 发表于 2024-7-26 23:48 | 显示全部楼层 |阅读模式
  1. h0=figure('toolbar','none',...
  2.     'position',[198 56 408 468],...
  3.     'name','实例53');
  4. h1=axes('parent',h0,...
  5.     'position',[0.15 0.5 0.7 0.5],...
  6.     'visible','off');
  7. [x,y]=meshgrid(-8:0.5:8);
  8. r=sqrt(x.^2+y.^2)+eps;
  9. z=sin(r)./r;
  10. fh=surf(x,y,z);
  11. shading interp
  12. view([-60 30])
  13. camlight left
  14. lightk=light('position',[0 -2 1]);
  15. button1=uicontrol('parent',h0,...
  16.     'style','pushbutton',...
  17.     'string','设置光线',...
  18.     'position',[80 60 70 30],...
  19.     'callback',[...
  20.         'an1=inputdlg(''光线来源的X轴坐标'');,',...
  21.         'k1=str2num(an1{1});,',...
  22.         'an2=inputdlg(''光线来源的Y轴坐标'');,',...
  23.         'k2=str2num(an2{1});,',...
  24.         'an3=inputdlg(''光线来源的Z轴坐标'');,',...
  25.         'k3=str2num(an3{1});,',...
  26.         'set(lightk,''position'',[k1 k2 k3]);,',...
  27.         'set(edit1,''string'',[''['',num2str(k1),'' '',num2str(k2),'' '',num2str(k3),'']'']);']);
  28. button2=uicontrol('parent',h0,...
  29.     'style','pushbutton',...
  30.     'string','关闭',...
  31.     'position',[250 60 70 30],...
  32.     'callback','close');
  33. edit1=uicontrol('parent',h0,...
  34.     'style','edit',...
  35.     'max',2,...
  36.     'min',0,...
  37.     'fontsize',15,...
  38.     'backgroundcolor',[1 1 1],...
  39.     'string','[0 -2 1]',...
  40.     'position',[80 110 220 30]);
  41. text1=uicontrol('parent',h0,...
  42.     'style','text',...
  43.     'backgroundcolor',[0.75 0.75 0.75],...
  44.     'fontsize',15,...
  45.     'string','光线来源坐标',...
  46.     'position',[80 140 220 30]);


VelvetStars 发表于 2025-6-15 19:12 | 显示全部楼层
感谢楼主分享,这个是用于什么场景
 楼主| cooldog123pp 发表于 2025-6-25 13:17 | 显示全部楼层
VelvetStars 发表于 2025-6-15 19:12
感谢楼主分享,这个是用于什么场景

回复帖子就能下载学习了,收到老铁的感谢,还会努力。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2224

主题

7415

帖子

31

粉丝
快速回复 在线客服 返回列表 返回顶部

2224

主题

7415

帖子

31

粉丝
快速回复 在线客服 返回列表 返回顶部