声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2066|回复: 2

[共享资源] 改变坐标轴范围!!

[复制链接]
发表于 2006-11-16 12:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
  1. h0=figure('toolbar','none', 'position',[198 56 408 468], 'name','实例4');
  2. h1=axes('parent',h0, 'position',[0.15 0.45 0.7 0.5], 'visible','on');
  3. e1=uicontrol('parent',h0, 'style','edit', 'string',1, 'position',[50 120 50 20]);
  4. t1=uicontrol('parent',h0, 'style','text', 'string','X轴最小值', 'position',[35 150 80 20]);
  5. e2=uicontrol('parent',h0, 'style','edit', 'string',5, 'position',[50 60 50 20]);
  6. t2=uicontrol('parent',h0, 'style','text', 'string','X轴最大值', 'position',[35 90 80 20]);
  7. e3=uicontrol('parent',h0, 'style','edit', 'string',1, 'position',[150 120 50 20]);
  8. t3=uicontrol('parent',h0, 'style','text', 'string','Y轴最小值', 'position',[135 150 80 20]);
  9. e4=uicontrol('parent',h0, 'style','edit', 'string',5, 'position',[150 60 50 20]);
  10. t4=uicontrol('parent',h0, 'style','text', 'string','Y轴最大值', 'position',[135 90 80 20]);
  11. e5=uicontrol('parent',h0, 'style','edit', 'string',20, 'position',[250 120 50 20]);
  12. t5=uicontrol('parent',h0, 'style','text', 'horizontalalignment','left', 'string','点数', 'position',[250 150 30 20]);
  13. b1=uicontrol('parent',h0, 'style','pushbutton', 'string','绘图', 'position',[250 60 60 40], ...
  14.         'callback',[ 'a=str2num(get(e1,''string'')); b=str2num(get(e2,''string''));,',...
  15.         'c=str2num(get(e3,''string'')); d=str2num(get(e4,''string'')); n=str2num(get(e5,''string''));,',...
  16.         'xgrid=linspace(-abs(a),abs(a),n); ygrid=linspace(-abs(b),abs(b),n);',...
  17.         '[x,y]=meshgrid(xgrid,ygrid); z=c*sqrt(d-y.*y/b/b-x.*x/a/a); u=1; z1=real(z);', ...
  18.         'for k=2:n-1, for j=2:n-1, if imag(z(k,j))~=0, z1(k,j)=0; end;',...
  19.         'if all(imag(z([k-1:k+1],[j-1:j+1])))~=0, z1(k,j)=nan; end; end; end;',...
  20.         'surf(x,y,z1); hold on, if u==1, z2=-z1; surf(x,y,z2),',...
  21.         'axis([-abs(a),abs(a),-abs(b),abs(b),-abs(c),abs(c)]); end;',...
  22.         'xlabel(''x''); ylabel(''y''); zlabel(''z''); hold off']);
  23. b2=uicontrol('parent',h0, 'style','pushbutton', 'string','关闭', 'position',[150 10 60 20], 'callback','close');
复制代码

[ 本帖最后由 ChaChing 于 2009-12-28 14:45 编辑 ]
回复
分享到:

使用道具 举报

发表于 2006-11-16 16:21 | 显示全部楼层
能不能稍微解释一下啊!
发表于 2006-11-20 08:22 | 显示全部楼层
原帖由 wangyongq246 于 2006-11-16 16:21 发表
能不能稍微解释一下啊!



这个程序好像没有太多需要解释的,代码很清晰
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-16 18:18 , Processed in 0.058025 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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